Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
AC (/≧▽≦)/限制深度的dfs#include <iostream> #include <stdio.h> #include <iomanip> #include <math.h> #include <string.h> #include <algorithm> #include <vector> #include <stack> #include <queue> #include <map> #include <set> #define inf 99999999 typedef long long ll; typedef unsigned long long ull; using namespace std; int a; ull n,flag; bool dfs(ull n,int deep) { if(deep>19)return 0; if(n%a==0) { cout<<n<<endl; return 1; } if(dfs(10*n,deep+1))return 1; if(dfs(10*n+1,deep+1))return 1; return 0; } int main() { while(cin>>a) { if(!a)return 0; flag=0; dfs(1,0); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator