2013 Asia Regional Changchun

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 }

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 }

end

2013 Asia Regional Changchun

时间: 2024-08-14 05:14:09

2013 Asia Regional Changchun的相关文章

2013 Asia Regional Changchun C

Little Tiger vs. Deep Monkey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total Submission(s): 960    Accepted Submission(s): 344 Problem Description A crowd of little animals is visiting a mysterious laboratory

HDU 4816 Bathysphere(数学)(2013 Asia Regional Changchun)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4816 Problem Description The Bathysphere is a spherical deep-sea submersible which was unpowered and lowered into the ocean on a cable, and was used to conduct a series of dives under the sea. The Bathys

HDU 4822 Tri-war(LCA树上倍增)(2013 Asia Regional Changchun)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4822 Problem Description Three countries, Red, Yellow, and Blue are in war. The map of battlefield is a tree, which means that there are N nodes and (N – 1) edges that connect all the nodes. Each country

2013 Asia Regional Changchun I 题,HDU(4821),Hash

题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=4821 解题报告:搞了很久,总算搞出来了,还是参考了一下网上的解法,的确很巧,和上次湘潭的比赛中的一个求平方和的题目思路很类似. 首先说一下hash,简单来说就是y = hash(x),有很多函数,可以参考这里:https://www.byvoid.com/blog/string-hash-compare/ 然后,我用的是这个:写法简单,而且重复的可能较小. // BKDR Hash Fu

(并查集)Travel -- hdu -- 5441(2015 ACM/ICPC Asia Regional Changchun Online )

http://acm.hdu.edu.cn/showproblem.php?pid=5441 Travel Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2061    Accepted Submission(s): 711 Problem Description Jack likes to travel around the wo

2015 ACM/ICPC Asia Regional Changchun Online HDU 5444 Elven Postman【二叉排序树的建树和遍历查找】

Elven Postman Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 591    Accepted Submission(s): 329 Problem Description Elves are very peculiar creatures. As we all know, they can live for a very

2015ACM/ICPC Asia Regional Changchun Online /HDU 5438 图

Ponds                                   Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)                                        Problem Description Betty owns a lot of ponds, some of them are connected with other

hdu 5444 Elven Postman(根据先序遍历和中序遍历求后序遍历)2015 ACM/ICPC Asia Regional Changchun Online

很坑的一道题,读了半天才读懂题,手忙脚乱的写完(套上模板+修改模板),然后RE到死…… 题意: 题面上告诉了我们这是一棵二叉树,然后告诉了我们它的先序遍历,然后,没了……没了! 反复读题,终于在偶然间注意到了这一句——"Not only that, when numbering the rooms, they always number the room number from the east-most position to the west." 它告诉我们,东边的点总是比西边的点

Hdu 5442 Favorite Donut (2015 ACM/ICPC Asia Regional Changchun Online 最大最小表示法 + KMP)

题目链接: Hdu 5442 Favorite Donut 题目描述: 给出一个文本串,找出顺时针或者逆时针循环旋转后,字典序最大的那个字符串,字典序最大的字符串如果有多个,就输出下标最小的那个,如果顺时针和逆时针的起始下标相同,则输出顺时针. 解题思路: 看到题目感觉后缀数组可以搞,正准备犯傻被队友拦下了,听队友解释一番,果断丢锅给队友.赛后试了一下后缀数组果然麻烦的不要不要的(QWQ),还是最大最小表示法 + KMP来的干净利索. 最大表示法:对于一个长度为len文本串,经过循环旋转得到长度