Hard Code http://acm.hdu.edu.cn/showproblem.php?pid=4813
#include<cstdio>
char op[];
int main(){
int t,n,m;
while(~scanf("%d",&t)){
while(t--){
scanf("%d%d%s",&n,&m,op);
for(int i=;i<n;i++){
for(int j=;j<m;j++){
printf("%c",op[i*m+j]);
}
puts("");
}
}
}
return ;
}
Little Tiger vs. Deep Monkey http://acm.hdu.edu.cn/showproblem.php?pid=4815
dp求n个数的和为j的种数,除以总的种数就是概率,一旦概率大于等于p就是答案。
#include<cstdio>
#include<cstring>
#define mt(a,b) memset(a,b,sizeof(a))
typedef __int64 LL;
LL dp[][];
int a[];
int main(){
int n,t;
double p;
scanf("%d",&t);
while(t--){
scanf("%d%lf",&n,&p);
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
mt(dp,);
dp[][]=;
for(int i=;i<=n;i++){
for(int j=;j<=;j++){
dp[i][j]+=dp[i-][j];
dp[i][j+a[i]]+=dp[i-][j];
}
}
LL sum=;
int ans=;
LL all=1LL<<n;
for(int i=;i<=;i++){
sum+=dp[n][i];
if(1.0*sum/all>=p){
ans=i;
break;
}
}
printf("%d\n",ans);
}
return ;
}
end