標籤:style blog http color os io for art
Hard Code http://acm.hdu.edu.cn/showproblem.php?pid=4813
1 #include<cstdio> 2 char op[1024]; 3 int main(){ 4 int t,n,m; 5 while(~scanf("%d",&t)){ 6 while(t--){ 7 scanf("%d%d%s",&n,&m,op); 8 for(int i=0;i<n;i++){ 9 for(int j=0;j<m;j++){10 printf("%c",op[i*m+j]);11 }12 puts("");13 }14 }15 }16 return 0;17 }View Code
Little Tiger vs. Deep Monkey http://acm.hdu.edu.cn/showproblem.php?pid=4815
dp求n個數的和為j的種數,除以總的種數就是機率,一旦機率大於等於p就是答案。
1 #include<cstdio> 2 #include<cstring> 3 #define mt(a,b) memset(a,b,sizeof(a)) 4 typedef __int64 LL; 5 LL dp[41][41010]; 6 int a[41]; 7 int main(){ 8 int n,t; 9 double p;10 scanf("%d",&t);11 while(t--){12 scanf("%d%lf",&n,&p);13 for(int i=1;i<=n;i++){14 scanf("%d",&a[i]);15 }16 mt(dp,0);17 dp[0][0]=1;18 for(int i=1;i<=n;i++){19 for(int j=0;j<=40000;j++){20 dp[i][j]+=dp[i-1][j];21 dp[i][j+a[i]]+=dp[i-1][j];22 }23 }24 LL sum=0;25 int ans=0;26 LL all=1LL<<n;27 for(int i=0;i<=40000;i++){28 sum+=dp[n][i];29 if(1.0*sum/all>=p){30 ans=i;31 break;32 }33 }34 printf("%d\n",ans);35 }36 return 0;37 }View Code
end