Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

DFS深搜1A!!!贴代码!

Posted by xuzhiyuan at 2018-04-07 09:48:04 on Problem 1426
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator