Find The Multiple(POJ1426)(入门)

来源:互联网 发布:mac phpmyadmin 配置 编辑:程序博客网 时间:2024/06/03 06:55

どこでもドア:http://poj.org/problem?id=1426

#include<iostream>#include<cstdio>#include<algorithm>#include<cmath>#include<cstring>#include<string>#include<sstream>#include<set>#include<cstdlib>#include<map>#include<queue>using namespace std;typedef long long LL;LL BFS(int n){    queue<LL> Q;    Q.push(1);    while(!Q.empty())    {        LL X = Q.front();        Q.pop();        if(X % n == 0)            return X;        Q.push(X * 10);        Q.push(X * 10 + 1);    }    return 0;}int main(){    int n;    while(cin>>n,n)    {        cout << BFS(n) << endl;    }}
0 0
原创粉丝点击