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 |
用C++超时 用G++AC 附代码#include <iostream> #include <queue> using namespace std; void search(int n) { queue<long long> Q; Q.push(1); while(!Q.empty()) { long long now; now=Q.front(); if(now%n==0) {cout<<now<<endl;return;} Q.pop(); Q.push(now*10); Q.push(now*10+1); } } int main() { int n; while(cin>>n&&n) { search(n); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator