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.
InputThe 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.OutputForeach test case you should output the total money a couple have to pay for their babies.
Sample Input2
2 5
0 0 1 1 1
2 2
0 0
Sample Output
70000 RMB
0 RMB
#include<stdio.h>
int main()
{
int nn[31];
nn[0] = 1;
for (int i = 1; i < 31; i++)
{
nn[i] = nn[i - 1] * 2;
}
int datanum;
scanf("%d", &datanum);
while (datanum--)
{
int num[2] = { 0 };
int n, m,num1,sum;
scanf("%d%d", &n, &m);
for (int i = 0; i < m; i++)
{
scanf("%d", &num1);
num[num1]++;
}
int k;
if (num[0] <= n)
{
k = num[1];
}
else
{
k = num[0] + num[1] - n;
}
sum = nn[k] - 1;
if (sum == 0)
{
printf("0 RMB\n");
}
else
{
printf("%d0000 RMB\n",sum);
}
}
return 0;
}
整体思路就是找到罚款的人数。
- 敏捷开发在互联网时代里的价值
- PL2586|替代FE1.1S|替代MA8601|USB2.0HUB集线器芯片|旺玖
- 力软快速开发平台,帮助中小企业躲过数字化“踏浪出海”的“暗礁”
- 软件开发:站在风口上的低代码
- TYPEC转HDMI方案|TYPEC扩展坞方案|CS5265设计4K60HZ TYPEC转HDMI方
- DP转HDMI2.0|DP转HDMI和VGA输出|CS5262AN方案应用|瑞奇达CS5262设计电
- Capstone瑞奇达|台湾瑞奇达|一级代理商|台湾瑞奇达科技有限公司
- CH7511B替代方案|CS5211设计方案|CS5211替代CH7511B|eDP转LVDS转接板
罚款的条件有二:
1.生的小孩大于规定的小孩数
2.生了男孩之后,就禁止生小孩。
if (num[0] <= n)
{
k = num[1];
}
比如我只能生4个小孩。于是我生了
1 0 0 0 一男孩,3女孩
按照你的逻辑mum[0]<4
k = num[1]=1
然而违规的小孩有三个,分别是三个女孩(生男孩之后不可以再生小孩)
k应该等于3.