HDU2103 Family planning【水题】

Family planning

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 7891    Accepted Submission(s): 2042

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

HDU 2007-6 Programming Contest

题目大意:小虎发明了一个计划生育方案:每对夫妇最多生M个孩子,超生的要罚款,但是

在这M个孩子里,如果生了男孩,就不能再生了,否则超生的也要罚款。罚款的数额和超生

个数有关,超生一个罚款10000元,超生第二个20000元,超生第三个40000元,每次都是

上一个的2倍。现在给你一对父母生的孩子个数N和最多生孩子个数M,以及N个孩子的性别。

求:她们要交多少钱的罚款。

思路:先求M个孩子里有木有男孩,有的话,从下一个孩子开始算超生的罚款,没有的话,就

从第M+1个孩子开始计算罚款。计算罚款的时候先按1、2、4元计算,输出的时候,在输出字

符串"0000",这样避免了数据溢出,注意答案为0的时候,不必再输出字符串。

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;

int a[33];
int main()
{
    int T;
    cin >> T;
    while(T--)
    {
        int N,M;
        cin >> M >> N;
        for(int i = 0; i < N; ++i)
            cin >> a[i];
        int ans = 0,pos = -1,Num;
        for(int i = 0; i < M; ++i)
            if(a[i] == 1)
            {
                pos = i;
                break;
            }

        if(pos != -1)
        {
            Num = 1;
            for(int i = pos+1; i < N; ++i)
            {
                ans += Num;
                Num *= 2;
            }
        }
        else
        {
            Num = 1;
            for(int i = M; i < N; ++i)
            {
                ans += Num;
                Num *= 2;
            }
        }
        if(ans != 0)
            cout << ans << "0000 RMB" << endl;
        else
            cout << "0 RMB" << endl;
    }

    return 0;
}
时间: 2024-08-03 00:03:42

HDU2103 Family planning【水题】的相关文章

【Floyd(并非水题orz)】BZOJ4093-[Usaco2013 Dec]Vacation Planning

最近刷水太多标注一下防止它淹没在silver的水题中--我成为了本题,第一个T掉的人QAQ [题目大意] Bovinia设计了连接N (1 < = N < = 20,000)个农场的航班.对于任何航班,指定了其中的k个农场作为枢纽. (1 < = K <= 200 , K < = N). 目前,共有M种单向航班( 1 < = M < = 20,000 ),第i个航班从农场u_i至农场v_i花费d_i ( 1 < = d_i < =10,000 )美元.

2015南阳CCPC L - Huatuo&#39;s Medicine 水题

L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these b

sdut 2841 Bit Problem (水题)

题目 贴这个题是因为看题解有更简单的方法, 我做的时候是直接算的, 也很简单. 贴一下题解吧: 如果一个整数不等于 0,那么该整数的二进制表示中至少有一位是 1. 这个题结果可以直接输出 x - (x&(x-1)); 因为x-1 之后二进制下,就是最右边的1变成了0, 最右边的1的 右边所有的0变成了1, 不影响最左边. 我的代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4

sdut 2413:n a^o7 !(第三届山东省省赛原题,水题,字符串处理)

n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you will step into a distinctive battleground which is full of sweet and happiness. If you want to win the battle, you must do warm-up according to my inst

杭电(hdu)2053 Switch Game 水题

Switch Game Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13113    Accepted Submission(s): 7970 Problem Description There are many lamps in a line. All of them are off at first. A series of o

4.7-4.9补题+水题+高维前缀和

题目链接:51nod 1718 Cos的多项式  [数学] 题解: 2cosx=2cosx 2cos2x=(2cosx)^2-2 2cos3x=(2cosx)^3-3*(2cosx) 数归证明2cos(nx)能表示成关于2cosx的多项式,设为f(n) f(1)=x,f(2)=x^2-2(其中的x就是2cosx) 假设n=1~k时均成立(k>=3) 当n=k+1时 由cos((k+1)x)=cos(kx)cos(x)-sin(kx)sin(x) cos((k-1)x)=cos(kx)cos(x)

历年NOIP水题泛做

快noip了就乱做一下历年的noip题目咯.. noip2014 飞扬的小鸟 其实这道题并不是很难,但是就有点难搞 听说男神错了一个小时.. 就是$f_{i,j}$表示在第$i$个位置高度为$j$的时候最小点击次数 递推的话对于上升的情况只做一次,后面几次在后面再做.. #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> using namespace st

[ZPG TEST 114] 阿狸的英文名【水题】

1.      阿狸的英文名 阿狸最近想起一个英文名,于是他在网上查了很多个名字.他发现一些名字可以由两个不同的名字各取一部分得来,例如John(约翰)的前缀 "John"和Robinson(鲁滨逊)的后缀 "son" 连在一起就是Johnson. 现在他找到了两个喜欢的名字(名字可看作字符串),用A和B表示,他想知道取A的一个非空前缀和B的一个非空后缀,连接在一起能组成多少不同的字符串. 输入格式 输入两行,分别表示字符串A和B:字符串只包含小写英文字母. 输出格

G - Brain Network (easy)(并查集水题)

G - Brain Network (easy) Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u CodeForces 690C1 Description One particularly well-known fact about zombies is that they move and think terribly slowly. While we still don't know

UVaLive 6591 &amp;&amp; Gym 100299L Bus (水题)

题意:略. 析:不解释,水题. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set>