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. linux-RPM 打包原理 SPEC 编写规范

    一.编写spec脚本 由前面的日志了解到,生成rpm除了源码外,最重要的就是懂得编写.spec脚本.rpm建包的原理其实并不复杂,可以理解为按照标准的格式整理一些信息,包括:软件基础信息,以及安装.卸 ...

  2. 【转】C++ 枚举类型的思考

    转自: http://blog.csdn.net/classfactory/article/details/87749 C++ 中的枚举类型继承于 C 语言.就像其他从 C 语言继承过来的很多特性一样 ...

  3. 解读Web应用程序安全性问题的本质

    转自 http://blog.csdn.net/iwebsecurity/article/details/1688304 相信大家都或多或少的听过关于各种Web应用安全漏洞,诸如:跨site脚本攻击( ...

  4. 【转载】MSXML应用总结 开发篇(上)

    原文:http://blog.sina.com.cn/s/blog_48f93b530100ejv9.html 本篇是接前文“MSXML应用总结 概念篇”写的,主要总结一下MSXML DOM接口的应用 ...

  5. 9 README,全套代码

    BBS+ BLOG系统(仿博客园) 一.概要 欢迎您使用该BBS+BLOG系统,希望在您使用的过程中体验到便捷和愉快的使用感受,并对我们的软件提出您发现的问题和建议,谢谢. 联系邮箱:liangshu ...

  6. C#中如果类的扩展方法和类本身的方法签名相同,那么会优先调用类本身的方法

    新建一个.NET Core项目,假如我们有如下代码: using System; namespace MethodOverload { static class DemoExtension { pub ...

  7. Storm 第三章 Storm编程案例及Stream Grouping详解

    1 功能说明 设计一个topology,来实现对文档里面的单词出现的频率进行统计.整个topology分为三个部分: SentenceSpout:数据源,在已知的英文句子中,随机发送一条句子出去. S ...

  8. [BZOJ3745][COCI2015]Norma[分治]

    题意 题目链接 分析 考虑分治,记当前分治区间为 \(l,r\) . 枚举左端点,然后发现右端点无非三种情况: 极大极小值都在左边; 有一个在左边; 极大极小值都在右边; 考虑递推 \(l\) 的同时 ...

  9. 关于自动化测试框架,所需代码技能,Java篇——参数配置与读取.

    前言: 说在前边.像我这种假期不出去浪,在这里乖乖写文章研究代码的人,绝壁不是因为爱学习,而是自己不知道去哪玩好,而且也不想玩游戏,看电视剧什么的,结果就无聊到看代码了…… 至于如何解读代码,请把它当 ...

  10. java并发编程——并发容器

    概述 java cocurrent包提供了很多并发容器,在提供并发控制的前提下,通过优化,提升性能.本文主要讨论常见的并发容器的实现机制和绝妙之处,但并不会对所有实现细节面面俱到. 为什么JUC需要提 ...