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

AC (/≧▽≦)/限制深度的dfs

Posted by 1243295518 at 2019-02-28 20:04:42 on Problem 1426
#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:
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