http://acm.hdu.edu.cn/showproblem.php?pid=2103

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.
 
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
2
2 5
0 0 1 1 1
2 2
0 0
 
Sample Output
70000 RMB
0 RMB
 
代码:

#include <bits/stdc++.h>
using namespace std; int a[50]; int main() {
int T;
scanf("%d", &T);
for(int i = 1; i <= T; i ++) {
int temp = 0;
int n, m, k;
scanf("%d%d", &m, &n);
double sum = 0;
for(int j = 1; j <= n; j ++)
scanf("%d", &a[j]); for(int j = 1; j <= n; j ++) {
if(a[j] == 1) {
temp = j;
break;
}
} if(n <= m) {
if(temp == 0 || temp == n) {
printf("0 RMB\n");
continue;
}
else
k = n - temp - 1;
}
else {
if(temp == 0)
k = n - m - 1;
else {
if(temp > m)
k = n - m - 1;
else
k = n - temp -1;
}
} for(int j = 0; j <= k; j ++)
sum += pow(2.0, j * 1.0);
sum = sum * 10000;
printf("%.0lf RMB\n", sum);
}
return 0;
}

  

HDU 2103 Family planning的更多相关文章

  1. HDOJ(HDU) 2103 Family planning(需要注意范围)

    Problem Description As far as we known,there are so many people in this world,expecially in china.Bu ...

  2. HDU 2103 Family Plan

    题目HDU 2103:http://acm.hdu.edu.cn/showproblem.php?pid=2103 Problem Description As far as we known,the ...

  3. HDU 3634 City Planning (离散化)

    City Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  4. hdu 3624 City Planning(暴力,也可扫描线)

    City Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) To ...

  5. HDU 4049 Tourism Planning(动态规划)

    Tourism Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  6. HDU 1158 Employment Planning (DP)

    题目链接 题意 : n个月,每个月都至少需要mon[i]个人来工作,然后每次雇佣工人需要给一部分钱,每个人每个月还要给工资,如果解雇人还需要给一笔钱,所以问你主管应该怎么雇佣或解雇工人才能使总花销最小 ...

  7. Hdu 1158 Employment Planning(DP)

    Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1158 一道dp题,或许是我对dp的理解的还不够,看了题解才做出来,要加油了. 只能先上代码了 ...

  8. hdu 4049 Tourism Planning [ 状压dp ]

    传送门 Tourism Planning Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Oth ...

  9. HDU 1158 Employment Planning

    又一次看题解. 万事开头难,我想DP也是这样的. 呵呵,不过还是有进步的. 比如说我一开始也是打算用dp[i][j]表示第i个月份雇j个员工的最低花费,不过后面的思路就完全错了.. 不过这里还有个问题 ...

随机推荐

  1. 20155234 2016-2017-2 《Java程序设计》第7周学习总结

    20155234 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 第十二章 Lambda Lambda表达式会使程序更加地简洁,在平行设计的时候,能够进行并行 ...

  2. 20155327 java第四周学习笔记

    20155327 java第四周学习笔记 五六章知识整理 1子类与父类 父类是接口或者是抽象类,子类必须继承自父类. 2子类的继承性 在Java中,通过关键字extends继承一个已有的类,被继承的类 ...

  3. linux 服务启动

    在linux上部署java服务的时候,发现服务启动正常,但是[ps -ef|grep java].[jps]看不到服务的运行. 查资料发现,[Java -jar Test.jar &      ...

  4. mfc 类对象数组

    知识点 类对象数组定义 类对象数组初始化 一.类对象数组定义 我们声明类对象数组,与我们申明内置类型数组的形式完全相同. 如: ]; ]; Tdate d[]; 二.类对象数组的初始化 .调用默认构造 ...

  5. python基础学习1-随机验证码

    import random i=random.randrange(65,90) #根据设置的范围生成随机数字 print(i) c=chr(i)#根据随机产生的数字 然后用chr生成对应ASCII 数 ...

  6. Python+Selenium UI自动化测试环境搭建及使用

    一什么是Selenium ? Selenium 是一个浏览器自动化测试框架,它主要用于web应用程序的自动化测试,其主要特点如下:开源.免费:多平台.浏览器.多语言支持:对web页面有良好的支持:AP ...

  7. ThinkPHP学习笔记(一)----初识ThinkPHP

    在做微信开发的时候原本使用来yii框架,后续觉得yii虽然功能强大使用方便,但是整个框架太大了,不适合一些轻量级的开发:这个时候发现thinkphp这个框架,框架本身很小,只有几M,但麻雀虽小,但五脏 ...

  8. 2.深入解析数据类型与变量——《Excel VBA 程序开发自学宝典》

    2.1 数据类型 数据类型 所占字节 Byte 1 Boolean 2 Integer 2 Long 4 Single 4 Double 8 Currency 8 Decimal 14 Date 8 ...

  9. ats 分层缓存

    了解缓存层次结构 缓存层次结构由彼此通信的缓存级别组成.ats支持多种类型的缓存层次结构. 所有缓存层次结构都识别父和子的概念. 父缓存是层次结构中较高的缓存, ats可以 将请求转发到该缓存.子缓存 ...

  10. sqli-labs学习笔记 DAY4

    DAY 4 sqli-labs lesson 23 与lesson 1一样,只不过屏蔽了#和–注释符. 报错型注入: 爆库:id=99' UNION SELECT 1,extractvalue(1,c ...