标签:
Time Limit: 1000MS | Memory Limit: 10000K | |||
Total Submissions: 22576 | Accepted: 9291 | Special Judge |
Description
Input
Output
Sample Input
2 6 19 0
Sample Output
10 100100100100100100 111111111111111111
题目大意:找到n的一个倍数,并且这个数只由0 1组成。
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <algorithm> 5 using namespace std; 6 int n; 7 bool flag; 8 unsigned long long m; 9 void dfs(unsigned long long x,int k) 10 { 11 cout<<x<<endl; 12 if(flag) 13 return; 14 if(x%n==0) 15 { 16 flag=1; 17 m=x; 18 return; 19 } 20 if(k==19) 21 return; 22 dfs(x*10,++k); 23 dfs(x*10+1,k); 24 return; 25 } 26 int main() 27 { 28 int i,j; 29 while(cin>>n&&n) 30 { 31 flag=0; 32 dfs(1,1); 33 cout<<m<<endl; 34 } 35 }
POJ Find The Multiple 1426 (搜索)
标签:
原文地址:http://www.cnblogs.com/a1225234/p/4903086.html