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 |
暴力破解,0-1背包#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator