HDU 2103 Family planning
http://acm.hdu.edu.cn/showproblem.php?pid=2103
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.
#include <bits/stdc++.h>
using namespace std; int a[50]; int main() {
int T;
scanf("%d", &T);
for(int i = 1; i <= T; i ++) {
int temp = 0;
int n, m, k;
scanf("%d%d", &m, &n);
double sum = 0;
for(int j = 1; j <= n; j ++)
scanf("%d", &a[j]); for(int j = 1; j <= n; j ++) {
if(a[j] == 1) {
temp = j;
break;
}
} if(n <= m) {
if(temp == 0 || temp == n) {
printf("0 RMB\n");
continue;
}
else
k = n - temp - 1;
}
else {
if(temp == 0)
k = n - m - 1;
else {
if(temp > m)
k = n - m - 1;
else
k = n - temp -1;
}
} for(int j = 0; j <= k; j ++)
sum += pow(2.0, j * 1.0);
sum = sum * 10000;
printf("%.0lf RMB\n", sum);
}
return 0;
}
HDU 2103 Family planning的更多相关文章
- HDOJ(HDU) 2103 Family planning(需要注意范围)
Problem Description As far as we known,there are so many people in this world,expecially in china.Bu ...
- HDU 2103 Family Plan
题目HDU 2103:http://acm.hdu.edu.cn/showproblem.php?pid=2103 Problem Description As far as we known,the ...
- HDU 3634 City Planning (离散化)
City Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- hdu 3624 City Planning(暴力,也可扫描线)
City Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- HDU 4049 Tourism Planning(动态规划)
Tourism Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 1158 Employment Planning (DP)
题目链接 题意 : n个月,每个月都至少需要mon[i]个人来工作,然后每次雇佣工人需要给一部分钱,每个人每个月还要给工资,如果解雇人还需要给一笔钱,所以问你主管应该怎么雇佣或解雇工人才能使总花销最小 ...
- Hdu 1158 Employment Planning(DP)
Problem地址:http://acm.hdu.edu.cn/showproblem.php?pid=1158 一道dp题,或许是我对dp的理解的还不够,看了题解才做出来,要加油了. 只能先上代码了 ...
- hdu 4049 Tourism Planning [ 状压dp ]
传送门 Tourism Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- HDU 1158 Employment Planning
又一次看题解. 万事开头难,我想DP也是这样的. 呵呵,不过还是有进步的. 比如说我一开始也是打算用dp[i][j]表示第i个月份雇j个员工的最低花费,不过后面的思路就完全错了.. 不过这里还有个问题 ...
随机推荐
- # 2017-2018-1 20155224 《信息安全系系统设计基础》第四周MyOD
2017-2018-1 20155224 <信息安全系系统设计基础>第四周MyOD 在这里跟老师先道歉,当时我的git没有安装好,后面也一直没有装上,所以程序没有git. 要求 参考教材第 ...
- 20155238 2016-2017-2 《Java程序设计》第四周学习总结
教材学习内容总结 继承 extends public class SwordsMan extends Role 检查语法逻辑,从=右边向左边读.编译程序就是语法检查器. 重新定义行为 public v ...
- 「PKUSC2018」最大前缀和
题面 题解 可以想到枚举成为最大前缀和的一部分的数 设\(sum_i=\sum\limits_{j\in i}a[j]\) 设\(f_i\)表示满足\(i\)的最大前缀和等于\(sum_i\)的方案数 ...
- Redis学习之路(一)之缓存知识体系
转自:https://www.unixhot.com/page/cache 缓存分层 缓存分级 内容 内容简介/主要技术关键词 用户层 DNS 浏览器DNS缓存 Firefox默认60秒,HTML5的 ...
- caffe windows编译
MicroSoft维护的caffe已经作为官方的caffe分支了,编译方式也改了,刚好最近重装了一次caffe windows, 记录一下里面的坑 https://github.com/BVLC/ca ...
- node.js学习笔记(一)——创建第一个应用
巧妇难为无米之炊.要学习node.js,当然必须先有node.js环境(可以去官网 http://nodejs.cn/ 下载安装),如果还是不懂怎么配置开发环境,度娘会告诉你一切. 安装完成环境之后, ...
- SSH结合EasyUI系统(一)———简单介绍
鉴于前文<不仅仅是吐槽>,决定将自己学过的和在学的东西整理一下放进园子:做一个好园友! 接下来将会持续更新的是近一段时间在学的java web中比较流行的框架SSH(Struts+Spri ...
- 获取本地ip和获取公网ip
import socket def get_local_ip(): ''' 获取本地ip地址 :return: ''' s = socket.socket(socket.AF_INET, socket ...
- Unity_屏幕/Viewport/世界坐标的转换
Unity_屏幕/Viewport/世界/UI坐标的转换 参考: https://www.jianshu.com/p/b5b6ac9ab145 -- 世界.视口.屏幕坐标转换 https://docs ...
- 算法工程师进化-SQL
1 引言 SQL操作往往是程序员必备的技能,对于算法工程师而言,熟练掌握SQL操作则更为重要.本文以<SQL语句执行顺序>作为学习资料,总结SQL的理论部分. 2 SQL查询语句的执行顺序 ...