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 ...
随机推荐
- 优秀的CSS预处理----Less
Less语法整理 本人邮箱:kk306484328@163.com,欢迎交流讨论. 欢迎转载,转载请注明网址:http://www.cnblogs.com/kk-here/p/7601058.html ...
- CA认证和颁发吊销证书
摘要:涉及到网络安全这一块,想必大家都听过CA吧.像百度.淘宝.京东等这些知名网站,每年都要花费一笔money来买CA证书.但其实简单的企业内的CA认证,我们自己就可以实现,今天小编我就讲解一下怎么在 ...
- 动易CMS - 设为首页代码和加入收藏代码(兼容各种浏览器)
注意: 这里虽然说是兼容,但是有些浏览器的设置就是不支持用js来把页面设为首页,加入收藏夹,只能让用户手动去在浏览器或者按键去设置这些功能,这里说的兼容是指当浏览器有这个设置的时候js会有提示. ...
- 常见sql技巧
一.一些常见的SQL实践 (1)负向条件查询不能使用索引 select * from order where status!=0 and stauts!=1 not in/not exists都不是好 ...
- 《effective Go》读后记录
一个在线的Go编译器 如果还没来得及安装Go环境,想体验一下Go语言,可以在Go在线编译器 上运行Go程序. 格式化 让所有人都遵循一样的编码风格是一种理想,现在Go语言通过gofmt程序,让机器来处 ...
- 怎样使用自定义标签简化 js、css 引入?
国庆将至,工作兴致全无,来总结点项目里平时不起眼干货. 前端引入 js .css 一般是这样: <script type="text/javascript" src=&quo ...
- 推荐系统相关算法(1):SVD
假如要预测Zero君对一部电影M的评分,而手上只有Zero君对若干部电影的评分和风炎君对若干部电影的评分(包含M的评分).那么能预测出Zero君对M的评分吗?答案显然是能.最简单的方法就是直接将预测分 ...
- 一文为你详细讲解对象映射库【AutoMapper】所支持场景
前言 在AutoMapper未出世前,对象与对象之间的映射,我们只能通过手动为每个属性一一赋值,时间长了不仅是我们而且老外也觉得映射代码很无聊啊.这个时候老外的所写的强大映射库AutoMapper横空 ...
- RobotFramework自动化测试框架-移动手机自动化测试Click Element关键字的使用
Click Element关键字用来模拟点击APP界面上的一个元素,该关键字接收一个参数[ locator ] ,这里的locator指的是界面元素的定位方式. 示例1:使用Click Element ...
- I/O输入输出流
I/O(输入/输出) 在变量.数组和对象中存储的数据是暂时存在的,程序结束后它们就会消失.为了能够永久地保存创建的数据,需要将其保存在磁盘文件中,这样可以在其他程序中使用它们. Java的I/O技术可 ...