| ||||||||||
| 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 | |||||||||
50A~ 贴下代码#include<iostream>
#include<queue>
using namespace std;
int main()
{
__int64 temp,te;
int n,tt;
bool flag[204];
while(cin>>n && n!=0){
memset(flag,false,sizeof(flag));
queue<__int64> q;
q.push(1);
while(!q.empty()){
temp=q.front();
q.pop();
if(temp%n==0){cout<<temp<<endl; break;}
else{
for(int i=0;i<2;i++){
tt=(temp*10+i)%n;
if(!flag[tt]){
flag[tt]=true;
te=temp*10+i;
q.push(te);
if(te%n==0)break;
}
}
if(te%n==0){cout<<te<<endl;break;}
}
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator