现在的位置: 首页 > 综合 > 正文

HUD 2103 Family planning(water)

2013年09月13日 ⁄ 综合 ⁄ 共 1972字 ⁄ 字号 评论关闭

Family planning

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


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
 


Source
 


Recommend
xhd
 
这个题目算是比较水的题目,最后还有半小时想随便挑一道试试,没想到这么水
这个题目我A了之后看了别人怎么做的,为什么这个题目AC率不是很高,看了下
大多数童鞋都是用的__int64其实是不需要的,因为最多30位,2^30还在int范围
之内,这个就比较清晰了,所以在求出结果的情况下直接加四个零就可以了,不
需要用其他的东西,更不需要用数组存储什么东西,这个题目只要找到分界点,
后面全部是要罚款的,还要注意的就是变态的测试数据一个也不允许生!
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int main()
{
int n,m,k;
bool flag;
int num;
int t,i;
int ans;
scanf("%d",&t);
while(t--)
{
ans=0;
num=1;
scanf("%d%d",&m,&n);
flag=1;
if(m==0)
flag=0;
for(i=0;i<n;i++)
{
scanf("%d",&k);
if(flag)
{
if(k==1 || i==m-1)
flag=0;
}
else
{
ans+=num;
num*=2;
}
}
if(ans>0)
printf("%d0000 RMB\n",ans);
else
printf("0 RMB\n");
}
return 0;
}

抱歉!评论已关闭.