| ||||||||||
| 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 | |||||||||
Re:DFS深搜1A!!!贴代码!In Reply To:DFS深搜1A!!!贴代码! Posted by:xuzhiyuan at 2018-04-07 09:48:04 > #include<cstdio>
> using namespace std;
> int n;bool suc;unsigned long long ans;
> void DFS(unsigned long long now,int step)
> {
> if(now%n==0){ans=now;suc=true;return;}
> if(step==19||suc) return;
> DFS(now*10,step+1);
> DFS(now*10+1,step+1);
> }
> int main()
> {
> while(scanf("%d",&n),n)
> {
> ans=suc=0;
> DFS(1,1);
> printf("%llu\n",ans);
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator