HDU2103 Family planning
来源:互联网 发布:小个子穿衣购买软件 编辑:程序博客网 时间:2024/05/01 22:34
Family planning
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10142 Accepted Submission(s): 2632
Problem Description
As far as we known,there are so many people in this world,expecially in china.But many people like LJ always insist on that more people more power.And he often says he will burn as much babies as he could.Unfortunatly,the president XiaoHu already found LJ's extreme mind,so he have to publish a policy to control the population from keep on growing.According the fact that there are much more men than women,and some parents are rich and well educated,so the president XiaoHu made a family planning policy:
According to every parents conditions to establish a number M which means that parents can born M children at most.But once borned a boy them can't born other babies any more.If anyone break the policy will punished for 10000RMB for the first time ,and twice for the next time.For example,if LJ only allowed to born 3 babies at most,but his first baby is a boy ,but he keep on borning another 3 babies, so he will be punished for 70000RMB(10000+20000+40000) totaly.
According to every parents conditions to establish a number M which means that parents can born M children at most.But once borned a boy them can't born other babies any more.If anyone break the policy will punished for 10000RMB for the first time ,and twice for the next time.For example,if LJ only allowed to born 3 babies at most,but his first baby is a boy ,but he keep on borning another 3 babies, so he will be punished for 70000RMB(10000+20000+40000) totaly.
Input
The first line of the input contains an integer T(1 <= T <= 100) which means the number of test cases.In every case first input two integers M(0<=M<=30) and N(0<=N<=30),N represent the number of babies a couple borned,then in the follow line are N binary numbers,0 represent girl,and 1 represent boy.
Output
Foreach test case you should output the total money a couple have to pay for their babies.
Sample Input
22 50 0 1 1 12 20 0
Sample Output
70000 RMB0 RMB
Source
HDU 2007-6 Programming Contest
本题题意为M表示一对夫妇应该生的孩子的数量,N表示实际生孩子的数量,如果第一次生的为男孩,则以后出生的孩子都要交罚款,如果在M数量内的孩子里面没有男孩,则超出M外的孩子要交罚款。由于最后结果了能会溢出,所以要进行处理。
#include <stdio.h>int a[35];int main(){int t,n,m;scanf("%d",&t);while(t --){scanf("%d%d",&m,&n);int flag = 0;long long sum = 0;for(int i = 0; i < n; i ++)scanf("%d",&a[i]);int money = 1;for(int i = 0; i < n; i ++){if(flag){sum += money;money *= 2;}if(a[i] && i < m)flag = 1;if(!flag && i >= m){sum += money;money *= 2;}}if(sum)printf("%lld0000 RMB\n",sum);elseprintf("0 RMB\n");}return 0;}
0 0
- HDU2103 Family planning【水题】
- hdu2103 Family planning
- HDU2103 Family planning
- Family planning
- Family planning
- Family planning
- Family planning
- hdu-2103-Family planning
- hdu 2103 Family planning
- Family planning 2103
- hdu 2103 Family planning
- hdu 2103 Family planning
- HDU 2103 Family planning
- HDOJ2103 Family planning
- HDOJ 2103 Family planning
- hdu2103
- hdu acm 2103 Family planning
- HUD 2103 Family planning(water)
- JVM性能调优
- MySQL使用规范
- poj_3122 Pie(二分)
- hdoj-【1465 不容易系列之一】
- PCB各层含义
- HDU2103 Family planning
- 错误Conflict with dependency 'com.google.code.findbugs:jsr305' 解决方法
- 360真不靠谱,云盘不靠谱 字体不靠谱 安全卫士不靠谱
- 关于计算机视觉(随谈)
- codeforces 734 C. Anton and Making Potions (二分 STL)
- 第13周项目5-拓扑排序算法验证
- 常用的HTTP请求方法和常见的HTTP相应的状态码
- 5分钟搞定android混淆
- command 5