Problem M
Computer Machinists (ACM) has sufferred from the Y2K bug and lost
some vital data for preparing annual report for MS Inc.
All what they remember is that MS Inc. posted a surplus or a
deficit each month of 1999 and each month when MS Inc. posted
surplus, the amount of surplus was s and each month when MS Inc.
posted deficit, the deficit was d. They do not remember which or
how many months posted surplus or deficit. MS Inc., unlike other
companies, posts their earnings for each consecutive 5 months
during a year. ACM knows that each of these 8 postings reported a
deficit but they do not know how much. The chief accountant is
almost sure that MS Inc. was about to post surplus for the entire
year of 1999. Almost but not quite.
Write a program, which decides whether MS Inc. suffered a deficit
during 1999, or if a surplus for 1999 was possible, what is the
maximum amount of surplus that they can post.
sequence of lines, each containing two positive integers s and
d.
of input, output one line containing either a single integer giving
the amount of surplus for the entire year, or output Deficit if it
is impossible.
237
743
849694
8000000
MS)
#include
using namespace std;
int main()
{
//freopen("in.txt", "r", stdin);
int
s=0,d=0,money=0,month=0;
while(~scanf("%d%d",&s,&d))
{
money=month=0;
for(int i=1;i<=6;i++)
if(s*i>=d*(5-i))
{
month=i-1;
break;
}//算出来五个月亏钱时最少亏钱月数
//printf("month=%d\n",month);
switch(month)
{
case 0:money=-12*d;break;
case 1:money=3*s-9*d;break;
case 2:money=6*s-6*d;break;
case 3:money=8*s-4*d;break;
case 4:money=10*s-2*d;break;
}
if(money<0)
printf("Deficit\n");
else
printf("%d\n",money);
}
return
0;
}
Problem M的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- [js高手之路] es6系列教程 - Set详解与抽奖程序应用实战
我们还是从一些现有的需求和问题出发,为什么会有set,他的存在是为了解决什么问题? 我们看一个这样的例子,为一个对象添加键值对 var obj = Object.create( null ); obj ...
- Linux 文件查找
在Linux系统的查找相关的命令: which 查看可执行文件的位置 whereis 查看文件的位置 locate 配合数据库查看文件位置 find 实际搜寻硬盘查询文件名称 whereis wher ...
- STM32获取DHT11温度传感器数据
准备物件 STM32F103C8T6核心板 ST-LINK V2 DHT11 杜邦线若干 连接线 STM32F103C8T6芯片管脚图 管脚说明 连接仿真器 STM32 ST-LINKV2 VCC V ...
- Opengl4.5 中文手册—F
索引 A B C D E F G H I J K L M N O P Q ...
- 移动端touch事件实现页面弹动--小插件
动手之前的打盹 说实话真的是好久没有更新博客了,最近一直赶项目,身心疲惫:最关键的是晚上还要回去上一波王者,实在是忙啊! 这周下来,清闲了些许,或许是因为要到国庆的缘故吧,大家都显得无精打采.俗话说的 ...
- 在JavaScript中使用json.js:Ajax项目之POST请求(异步)
经常在百度搜索框输入一部分关键词后,弹出候选关键热词.现在我们就用Ajax技术来实现这一功能. 一.下载json.js文件 百度搜一下,最好到json官网下载,安全起见. 并与新建的两个文件部署如图 ...
- 使用Xshell+Xmanager远程监控jvisualvm
使用jvisualvm的remote方式监控服务器端jvisualvm时,不是很方便,因此通过local方式,应该是正路. 一.服务器端(Linux,最小安装模式,没有图形界面) 1.安装xauth ...
- Two Sum IV - Input is a BST
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST s ...
- 关于如何获取iframe中的元素
今天研究了一下iframe中元素的获取,发现有些地方还是有点坑的. 首先:如果使用纯前端手段,是没有办法获取非同源的iframe中的元素的,后面会提到后端手段 一.同源环境 1.首先在父页面获取ifr ...
- Java高新技术 注解
Java高新技术 注解 知识概要: (1)了解注解 (2)注解的应用结构图 (3)@Retention(RetentionPolicy.RUNTIME) ...