[ACM ] 題號151 跑幾個測資沒問題但WA
看板C_and_CPP (C/C++)作者tw00088437 (喵貓 loves fish)時間16年前 (2009/11/03 00:10)推噓0(0推 0噓 3→)留言3則, 1人參與討論串1/1
題號:
151
http://tinyurl.com/ygvjmsf
遇到的問題:
自己跑幾個測資沒問題 但送出後WA 不知問題在哪
有問題的code: (請善用置底文的標色功能)
#include<iostream>
using namespace std;
int a,i,m,count;
int main()
{
while(cin>>a)
{
if(!a)
break;
for(m=2;m>=1;m++)//try m and find the min
{
int t=0;
int c=0; //start:region 1
int count=m-1;
bool s=0;
bool store[100]={0};
for(i=0;i<a;i++)//at the beginning,0~a-1 is opened
store[i]=1;
while(t!=a-1) //t = how many already powered down,wanna turn
down a-2 then break
{
if(store[c%a])
{
count++;//count = how many step(skipped) advanced
if(count==m)
{
s=1; //s: gotta turn off !
count=0;
}
}
if(s&&store[c%a])
{
s=0;
store[c%a]=0;
t++;
}
c++; //c increment anyway
}
if(store[12]) //check if the last one is #13
{
break;
}
}
cout<<m<<endl;
}
return 0;
}
補充說明:
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.101.188
→
11/04 00:26, , 1F
11/04 00:26, 1F
→
11/04 00:26, , 2F
11/04 00:26, 2F
→
11/04 00:26, , 3F
11/04 00:26, 3F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章