| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
用stl模拟 严重超时~!!!在本地打表后还是AC了 花了20分钟 无语....#include<iostream>
#include<cmath>
#include<cstring>
#include<deque>
#include<algorithm>
using namespace std;
deque<int>line;
void tran(void)
{
int temp;
temp=line.front();
line.pop_front();
line.push_back(temp);
}
int main ()
{
int k;
int i;
int j;
int flag;
int m;
int num;
while(scanf("%d",&k))
{
if(k==0)
break;
m=0;
while(++m)
{
num=0;
for(i=0;i<k;i++)
{
line.push_back(0);
}
for(i=0;i<k;i++)
{
line.push_back(1);
}
while(1)
{
for(j=1;j<m;j++)
{
tran();
}
if(line.front()==1)
{
num++;
if(num==k)
goto next;
}
if(line.front()==0)
{
line.clear ();
break;
}
line.pop_front ();
}
}
next:
printf("%d\n",m);
line.clear ();
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator