| ||||||||||
| 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 | |||||||||
牛人帮忙看看代码,为什么老是MLE呢?#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator