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. jQuery学习- 子选择器与可见性选择器

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. 2-[Mysql]- 初识sql语句

    1.统一字符编码  强调:配置文件中的注释可以有中文,但是配置项中不能出现中文 mysql> \s # 查看字符编码 # 1.在mysql的解压目录下,新建my.ini,然后配置 #mysql5 ...

  3. 5 功能4:个人站点页面设计(ORM跨表与分组查询)

    1.个人站点页面文章的查询 # 个人站点 http://www.cnblogs.com/wh1520577322/ http://www.cnblogs.com/liucong12345/ http: ...

  4. BZOJ 2818 GCD 素数筛+欧拉函数+前缀和

    题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=2818 题意:给定整数N,求1<=x,y<=n且Gcd(x,y)为素数的数对( ...

  5. 2_C语言中的数据类型 (四)整数与无符号数

    1.1       sizeof关键字 sizeof是c语言关键字,功能是求指定数据类型在内存中的大小,单位:字节 sizeof与size_t类型 1.1       int类型 1.1.1      ...

  6. Convert Application Model Differences

    The eXpressApp Framework is based on the modules concept. As a rule, every module implements a certa ...

  7. 微信小程序中的 web-view 组件

    web-view 是一个可以承载 web 网页的容器,当 WXML 文件中存在 web-view 组件时,其他组件会自动全部失效,而且 web-view 承载的组件会自动铺满小程序的整个页面.其他组件 ...

  8. 简单可行的code review规则

    前言 曾经有一段垃圾代码放在我的面前,我没有拒绝,等我真正开始接手的时候我才后悔莫及,程序员最痛苦的事莫过于此! 每当接手别人的代码,都有一种想重新写一遍的感觉,等到别人再来接手你的代码时,同样的感觉 ...

  9. pandas安装以及出现的问题

    pandas安装以及出现的问题 1.pandas 安装 pandas是Python的第三方库,所以使用前需要安装一下,直接使用pip install pandas就会自动安装,安装成功后显示的以下的信 ...

  10. python迭代器的内置函数

    1.迭代器: 内置函数: (1)iter() -__iter__() (2)next() -__next__() 2.迭代器的举例; 对于Fibs数列,我们对其进行 限量输出: 实现代码如下: cla ...