Family planning

在草稿箱呆了好几年了,才放出来

                                        Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
                                                              Total Submission(s): 11294    Accepted Submission(s): 2971

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
题目要求:本题的大概意思就是求不按规则生娃要交多少罚款?规则有两条:1.不能超生。 2.即使没有超生,但生完男娃后就不能再生啦。(注意第一个男娃是免费的,我由于忽略了这个问题,结果第一次提交wa掉)
c语言代码:(在草稿箱呆了好几年了,才放出来
#include<stdio.h>
int main()
{
int t,m,n,i,a;
scanf("%d",&t);
while(t--)
{
long long int sum=0,ss=10000,l=0,ll=0;
scanf("%d%d",&m,&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a);
if(ll==0&&i<=m&&a==1)
{ll=1;continue;
}
if(i<=m&&ll>0)  l++;               //计算有多少个不和规矩的娃
if(i>m)    l++;                           //这是超生的娃
}
for(i=1;i<=l;i++)                             //计算罚款
{
sum+=ss;
ss*=2;
}
printf("%lld RMB\n",sum);
}
return 0;
}

杭电2103---Family planning相关推荐

  1. hdoj杭电问题分类

    杭电上的题虽然多,但是一直苦于找不到问题分类,网页都是英文的,所以平时做题也没怎么看,今天仔细一看,问题分类竟然就在主页....做了那么久的题居然没发现,表示已经狗带..不要笑,不知道有没有像我一样傻 ...

  2. 杭电acm第2304题答案c语言,【转】杭电ACM试题分类

    注:网上搜的 第一篇 1001 这个就不用说了吧 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 ...

  3. 杭电acm2151题java的解法,杭电ACM题型分类

    杭电ACM题型分类 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1 ...

  4. 杭电OJ分类题目(3)

    原题出处:HDOJ Problem Index by Type,http://acm.hdu.edu.cn/typeclass.php 杭电OJ分类题目(3) HDU Computational Ge ...

  5. 杭电ACM(HDUOJ)试题分类

    杭电ACM试题分类 第一篇 1001 这个就不用说了吧                      1002 简单的大数                            1003 DP经典问题,最 ...

  6. 杭电46道DP牛人总结

    原文地址:杭电46道DP牛人总结作者:飞泉鸣玉 杭电46道DP牛人总结 HDU 动态规划(46道题目)倾情奉献~ [只提供思路与状态转移方程] 收藏 Robberies http://acm.hdu. ...

  7. 杭电ACM题目类型整理

    版权声明:(╯3╰) 转载请注明: http://blog.csdn.net/bat67 杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 10 ...

  8. 【杭电ACM】1097 A hard puzzle

    [杭电ACM]1097  A hard puzzle http://acm.hdu.edu.cn/showproblem.php?pid=1097 先用int手写了算法结果竟然wrong answer ...

  9. 【ACM】杭电OJ 1106 函数atoi

    函数atoi是把字符串转化成整数的函数,头文件为 #include "stdlib.h" e.g. 运行环境:Dev-C++ 5.11 杭电1106 调用了sort函数,运行的时间 ...

  10. 【ACM】杭电OJ 2037

    题目链接:杭电OJ 2037 先把b[i]进行排序,然后,b[i]与a[i+1]进行比较. #include <iostream> #include <cstdio> #inc ...

最新文章

  1. 低版本jdbc连接高版本oracle,转:oracle11g的JDBC连接 URL和之前的版本有一定的区别...
  2. SecureCRT上传下载文件
  3. Python 经典模块可能都学过,10道题测试你会不会用?
  4. 信息安全工程师笔记-网络安全主动防御技术与应用
  5. 安卓学习笔记44:开源框架okhttp3入门
  6. python使用glob模块匹配文件及路径
  7. 服务器为什么要装操作系统,服务器需要安装操作系统吗
  8. 查找工资前三高的员工
  9. 化工人员定位安全管理系统解决方案
  10. VR系列——Oculus Audio sdk文档:一、虚拟现实音频技术简介(5)——环境建模
  11. Java根据图片提取文字
  12. ROS中Remap标签详解,举例说明其两种用法
  13. Kylin(二)安装使用
  14. linux -bash: ipconfig: command not found
  15. 紧扣时髦潮水 OPPO U701珍珠红亮相
  16. Yii2 User 登录原理
  17. 拓扑数据分析-Topological data analysis
  18. php+手办,不做成HUB真可惜了 桌面新摆件诞生——ROG官方手办
  19. 夺命雷公狗—玩转SEO---28---DEDE快排关键词快速速录文章发表技术总汇
  20. Innotop简单介绍

热门文章

  1. underscore源码经典--收藏
  2. FastReport studio 动态加载数据集 (zhuan)
  3. 微信公众号-回复消息触发时间绑定EventKEY
  4. 2019年在中国每个人都可能拥有百万元收入
  5. 虚拟仪器的python实现_基于Python的虚拟仪器技术探究及实现.pdf
  6. field list什么意思_什么是生物信息学?
  7. 控制图的绘制步骤_实战!脚手架排布图绘制步骤和技巧讲解!图文展示
  8. 4gl 上传文件_速看!关于浙江移动微法院新版图文上传和签名的使用说明
  9. PX4 FMU [7] rgbled [转载]
  10. try-expect在集合处理中的应用