标签:des style blog color java os io strong for
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 592 Accepted Submission(s): 273
1 #include<iostream> 2 #include<string> 3 #include<cstdio> 4 #include<vector> 5 #include<queue> 6 #include<stack> 7 #include<set> 8 #include<algorithm> 9 #include<cstring> 10 #include<stdlib.h> 11 #include<math.h> 12 #include<map> 13 using namespace std; 14 #define ll long long 15 int num[10]; 16 int dfs(int n){ 17 for(int i=1;i<=6&&n>=i;i++){ 18 if(num[i]<4){ 19 num[i]++; 20 if(!dfs(n-i)){ 21 num[i]--; 22 return 1; 23 } 24 num[i]--; 25 } 26 } 27 return 0; 28 } 29 int main(){ 30 #ifndef ONLINE_JUDGE 31 freopen("input.txt","r" ,stdin); 32 #endif // ONLINE_JUDGE 33 string a; 34 while(cin>>a){ 35 int sum=0; 36 memset(num,0,sizeof(num)); 37 for(int i=0;i<a.size();i++) num[a[i]-‘0‘ ]++,sum+=a[i]-‘0‘; 38 cout<<a<<" "; 39 if(dfs(31-sum)) { 40 if(a.size()&1) cout<<"B"; 41 else cout<<"A"; 42 } 43 else { 44 if(a.size()&1) cout<<"A"; 45 else cout<<"B"; 46 } 47 cout<<endl; 48 } 49 }
标签:des style blog color java os io strong for
原文地址:http://www.cnblogs.com/ainixu1314/p/3934729.html