HDU 2103 水
来源:互联网 发布:蚂蚁讨厌什么味道 知乎 编辑:程序博客网 时间:2024/06/16 16:29
Family planning
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8757 Accepted Submission(s): 2267
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
#include<iostream>
#include<cmath>
using namespace std;
long long powe(int n);
int main()
{
int T=0;
scanf("%d",&T);
while(T--)
{
int n=0,m=0;
long long sum=0;
int a[50]={0};
scanf("%d%d",&m,&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
}
if(n<m)
{
for(int i=1;i<=n;i++)
{
if(a[i])
{
sum=n-i;
break;
}
}
}
else
{
for(int i=1;i<=m;i++)
{
if(a[i])
{
sum=n-i;
break;
}
}
if(sum==0)
{
sum=n-m;
}
}
long long ans=0;
ans=(powe(sum)-1)*10000;
printf("%lld RMB\n",ans);
}
return 0;
}
long long powe(int n)
{
long long sum=1;
for(int i=1;i<=n;++i)
sum*=2;
return sum;
}
0 0
- HDU 2103 水
- HDU 2103
- hdu 2103
- hdu 2103
- hdu 2103 Family planning (水)
- HDU 2103 Family planning(水~)
- hdu 2222 hdu 3065 hdu 2896 AC自动机水题
- hdu 1250 hdu 1130 java水大数
- HDU 2111--Saving HDU【贪心水题】
- HDU 2107 Founding of HDU(水~)
- HDU 2109 Fighting for HDU(水~)
- HDU 2103 Family Plan
- hdu-2103-Family planning
- hdu 2103 Family planning
- hdu 2103 Family planning
- hdu 2103 Family planning
- Hdu 2103解题报告
- HDU 2103 Family planning
- 【学习笔记】c++ 类 重载运算符
- 为button添加监听事件
- ThinkPHP--各种查询条件设置
- hdu5489 ||2015合肥网络赛1006 dp+离散化树状数组优化
- This is it——Before my body is dry
- HDU 2103 水
- Java六大必须理解的问题--Java基础
- Android基础学习之Notification(通知)
- 面向对象的一大堆
- 多界面的跳转
- USACO Name That Number(水题暴力)
- iOS之CoreData
- ThinkPHP--聚合函数及having使用细节
- C++编译过程中的错误集锦集锦(持续更新)