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

用C++超时 用G++AC 附代码

Posted by 268123lry at 2015-07-15 22:09:34 on Problem 1426
#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:
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