题目意思很简单 : 就是找一个十进制的数,全由 1 0 组成,是输入那个数字的整数倍
答案有很多种,所以是special judge
需要用到 : 同余取模定理 广搜
因为是广搜我们就可以用栈 当然也可以用数组
#include<stdio.h>
#include<queue>
using namespace std;
void dfs(int x)
{
queue<long long>q;
while(!q.empty())
q.pop();
q.push(1);
long long temp=1;
while(!q.empty()){
if(temp%x==0){
printf("%lld\n",temp);
return ;
}
temp=q.front();
q.pop();
temp=temp*10;
q.push(temp+1);
q.push(temp);
}
}
int main()
{
int n;
while(scanf("%d",&n),n)
dfs(n);
return 0;
}