看板 C_and_CPP 關於我們 聯絡資訊
題號: 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
tw00088437:有另外一題類似的 只是要求最後一個地方要停在2號 11/04 00:26
tw00088437:我只把STORE[12]改成STORE[1]傳上去就對了 11/04 00:26
tw00088437:不知道問題在哪 = = ? 11/04 00:26