Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

用stl模拟 严重超时~!!!在本地打表后还是AC了 花了20分钟 无语....

Posted by abilitytao at 2008-11-05 18:30:42 on Problem 1012
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator