Friends
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 556 Accepted Submission(s): 283
Problem Description
Mike has many friends. Here are nine of them: Alice, Bob, Carol, Dave, Eve, Frank, Gloria, Henry and Irene.
Mike is so skillful that he can master n languages (aka. programming languages).
His nine friends are all weaker than he. The sets they can master are all subsets of Mike's languages.
But the relations between the nine friends is very complex. Here are some clues.
1. Alice is a nice girl, so her subset is a superset of Bob's.
2. Bob is a naughty boy, so his subset is a superset of Carol's.
3. Dave is a handsome boy, so his subset is a superset of Eve's.
4. Eve is an evil girl, so her subset is a superset of Frank's.
5. Gloria is a cute girl, so her subset is a superset of Henry's.
6. Henry is a tall boy, so his subset is a superset of Irene's.
7. Alice is a nice girl, so her subset is a superset of Eve's.
8. Eve is an evil girl, so her subset is a superset of Carol's.
9. Dave is a handsome boy, so his subset is a superset of Gloria's.
10. Gloria is a cute girl, so her subset is a superset of Frank's.
11. Gloria is a cute girl, so her subset is a superset of Bob's.
Now Mike wants to know, how many situations there might be.
Input
The first line contains an integer T(T≤20) denoting the number of test cases.
For each test case, the first line contains an integer n(0≤n≤3000), denoting the number of languages.
Output
For each test case, output ''Case #t:'' to represent this is the t-th case. And then output the answer.
Sample Input
2
0
2
Sample Output
Case #1: 1
Case #2: 1024
Source
The 2015 ACM-ICPC China Shanghai Metropolitan Programming Contest
不会java ~
思路:32^n 大数乘法
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#define CLR(arr,x) memset(arr,x,sizeof(arr))
#define FOR(i,j,n) for(j=i;j<n;++j)
#define FOR2(i,j,n) for(j=i;j>=n;--j)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
using namespace std ;
const int maxn = 3000+100;
const int inf = 0x3f3f3f3f ;
int ans[maxn][5000+1] ;
void And() {
int i , j , k ;
CLR(ans,0) ;
ans[1][0] = 2 , ans[1][1] = 3;
FOR(2,i,3001) {
FOR(0,k,2){
FOR(0,j,5000){
ans[i][j+k] += ans[1][k]*ans[i-1][j] ;
}
}
FOR(0,j,5000) {
ans[i][j+1] += ans[i][j]/10 ;
ans[i][j] = ans[i][j]%10 ;
}
}
}
int main() {
int t , i , j , n , cas = 1;
cin >>t ;
And() ;
while(t--) {
scanf("%d",&n) ;
printf("Case #%d: ",cas++) ;
if(!n) cout << 1 << endl ;
FOR2(5000,i,0){
if(ans[n][i]) {
FOR2(i,j,0) {
printf("%d",ans[n][j]) ;
}
printf("\n") ;
break;
}
}
}
return 0 ;
}