poj1426(dfs)

题目连接:http://poj.org/problem?id=1426

纯属水过,,看到别人说结果不会超long long。。。。没有证明

 1 #include<cstdio>
 2 #include<cstring>
 3 #define ll long long
 4 int ok,n;
 5 
 6 void dfs(ll x,int d)
 7 {
 8     if(ok||d>=19) return;
 9     if(x%n==0)
10     {
11         printf("%lld\n",x);
12         ok=1;
13         return ;
14     }
15     dfs(x*10,d+1);
16     dfs(x*10+1,d+1);
17 }
18 int main()
19 {
20   while(scanf("%d",&n)&&n)
21   {
22       ok=0;
23       dfs(1,0);
24   }
25   return 0;
26 }

 

posted @ 2017-04-13 15:37  yijiull  阅读(112)  评论(0编辑  收藏  举报