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

牛人帮忙看看代码,为什么老是MLE呢?

Posted by Ontheline at 2009-03-13 17:55:56 on Problem 1426
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <iomanip>
#include <sstream>
#include <queue>
using namespace std;
queue<int> q;
int f[200];
int main()
{
	int n;
	while (cin >> n&& n!=0)
	{
		memset(f,0,sizeof(int)*200);
		string str;
		q.push(1);
		str.insert(0,(char)(1+'0'));
		int s,news;
		news=200;
		while (news>0)
		{
			if (!q.empty())
			{
				s=q.front();
				q.pop();
				news=(s*10)%n;
				str.insert(str.end(),'0');
			}
			else
			{
				news=s%n;
			}
			if (f[news]==0)
			{
				q.push(news);
				f[news]=1;
			}
			else
			{
				s=news*10+1;
				str.insert(str.end(),(char)(1+'0'));
			}

		}
		cout << str << endl;
		while (!q.empty())
		{
			q.pop();
		}
		
	}
	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