标签:des style blog http color java os io
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 938 Accepted Submission(s): 276
1 #include<stdio.h> 2 #include<math.h> 3 #include<string.h> 4 #include<algorithm> 5 using namespace std; 6 int arr[40320*9]; 7 int main() 8 { 9 int n,m,x,k,i,j,beg,flag,number; 10 int num[10]; 11 while(scanf("%d%d",&n,&m)!=EOF) 12 { 13 memset(arr,0,sizeof(arr)); 14 for(i=0;i<n;i++) 15 scanf("%d",&num[i]); 16 sort(num,num+n); 17 i=0; 18 do 19 { 20 if(num[0]) 21 { 22 number=0; 23 int t=n; 24 for(j=0;j<n;j++) 25 number+=num[j]*pow(10,--t); 26 arr[i++]=number; 27 beg=i; 28 } 29 }while(next_permutation(num,num+n)); 30 while(m--) 31 { 32 scanf("%d%d",&x,&k); 33 flag=1; 34 for(i=0;i<beg;i++) 35 if( (arr[i] + x)%k == 0 ) 36 { 37 printf("%d\n",arr[i]); 38 flag=0; 39 break; 40 } 41 if(flag) 42 printf("None\n"); 43 } 44 } 45 return 0; 46 }
ACM HDU 1755 -- A Number Puzzle,布布扣,bubuko.com
ACM HDU 1755 -- A Number Puzzle
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/yeshadow937/p/3913026.html