Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 13271 Accepted Submission(s): 6095
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PI(x) printf("%d",x)
#define PL(x) printf("%lld",x)
#define P_ printf(" ")
#define T_T while(T--)
typedef long long LL;
LL dp[40];
int main(){
int T,N;
dp[0]=0;
for(int i=1;i<=35;i++)dp[i]=3*dp[i-1]+2;
while(~SI(N))PL(dp[N]),puts("");
return 0;
}
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5517 Accepted Submission(s): 3985
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PI(x) printf("%d",x)
#define PL(x) printf("%lld",x)
#define P_ printf(" ")
#define T_T while(T--)
typedef long long LL;
LL dp[40];
int main(){
int T,N;
dp[0]=0;
for(int i=1;i<=35;i++)dp[i]=3*dp[i-1]+2;
SI(T);
T_T{
SI(N);
PL(dp[N-1]+2);puts("");
}
return 0;
}
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3801 Accepted Submission(s): 2248
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int INF=0x3f3f3f3f;
#define mem(x,y) memset(x,y,sizeof(x))
#define SI(x) scanf("%d",&x)
#define SL(x) scanf("%lld",&x)
#define PI(x) printf("%d",x)
#define PL(x) printf("%lld",x)
#define P_ printf(" ")
#define T_T while(T--)
typedef long long LL;
LL dp[65][65];
int main(){
int T,N,k,cur;
for(int i=1;i<=60;i++){
cur=0;
for(int j=i;j>=1;j--){
dp[i][j]=(LL)1<<cur;
cur++;
}
}
SI(T);
T_T{
SI(N);SI(k);
PL(dp[N][k]);puts("");
}
return 0;
}
原文:http://www.cnblogs.com/handsomecui/p/5171361.html