标签:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
#define LL long long
queue<LL> q;
LL n;
LL bfs()
{
    LL x;
    while(!q.empty()) q.pop();
    q.push(1);
    while(!q.empty())
    {
        x=q.front(),q.pop();
        if(x%n==0)
            return x;
        q.push(x*10);
        q.push(x*10+1);
    }
}
int main()
{
    while(scanf("%I64d",&n)!=EOF)
    {
        if(n==0)
            break;
        printf("%I64d\n",bfs());
    }
    return 0;
}
标签:
原文地址:http://www.cnblogs.com/a972290869/p/4288266.html