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

暴力破解,0-1背包

Posted by 508618087 at 2012-05-13 20:48:54 on Problem 1426
#include<stdio.h>
#include <stdlib.h>
#include <iostream>
int s=0;

using namespace std;
void bag(__int64 p,int n,int k)
{
	if(s==1||k==20)
		return;
	if(p%n==0)
	{
		printf("%I64u\n",p);
		s=1;
	}
	else
	{
		bag(10*p,n,k+1);
		bag(10*p+1,n,k+1);		
	}
}

int main()
{
	int n;
	while(cin>>n,n)
	{
		s=0;
		bag(1,n,1);
	}
	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