题意: 有一个公司由于某个病毒使公司赢亏数据丢失,但该公司每月的 赢亏是一个定数,要么一个月赢利s,要么一月亏d。现在ACM只知道该公司每五个月有一个赢亏报表,而且每次报表赢利情况都为亏。在一年中这样的报表总共有8次(1到5,2到6,…,8到12),现在要编一个程序确定当赢s和亏d给出,并满足每张报表为亏的情况下,全年公司最高可赢利多少,若存在,则输出多多额,若不存在,输出"Deficit"。
 
分析:
在保证连续5个月都亏损的前提下,使得每5个月中亏损的月数最少。
              x=1:  ssssd,ssssd,ss    d>4s     赢利10个月  10s-2d
              x=2:  sssdd,sssdd,ss    2d>3s    赢利8个月     8s-4d
              x=3:  ssddd,ssddd,ss    3d>2s    赢利6个月     6s-6d 
              x=4:  sdddd,sdddd,sd    4d>s     赢利3个月     3s-9d
              x=5:  ddddd,ddddd,dd    4d<s     无赢利

 

#include <stdio.h>
#include <string.h>
int main()
{
long long s,d,sum;
while (scanf("%lld%lld",&s,&d)!=EOF)
{
sum=0;
if(d>4*s)
sum=10*s-2*d;
else if(2*d>3*s)
sum=8*s-4*d;
else if(3*d>2*s)
sum=6*s-6*d;
else if(4*d>s)
sum=3*s-9*d;
else sum=-1;
if (sum<0)
printf ("Deficit\n");
else printf ("%lld\n",sum); }
return 0;
}

Y2K Accounting Bug(poj2586)的更多相关文章

  1. poj2586 Y2K Accounting Bug(贪心)

    转载请注明出处:http://blog.csdn.net/u012860063?viewmode=contents 题目链接:http://poj.org/problem?id=2586 ------ ...

  2. POJ 2586:Y2K Accounting Bug(贪心)

    Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10024 Accepted: 4990 D ...

  3. POJ 2586 Y2K Accounting Bug(枚举洪水问题)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10674   Accepted: 53 ...

  4. POJ 2586 Y2K Accounting Bug(枚举大水题)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10674   Accepted: 53 ...

  5. [POJ 2586] Y2K Accounting Bug (贪心)

    题目链接:http://poj.org/problem?id=2586 题目大意:(真难读懂啊)给你两个数,s,d,意思是MS公司每个月可能赚钱,也可能赔钱,如果赚钱的话,就是赚s元,如果赔钱的话,就 ...

  6. POJ 2586 Y2K Accounting Bug(贪心)

    题目连接:http://poj.org/problem?id=2586 题意:次(1-5.2-6.3-7.4-8.5-9.6-10.7-11.8-12),次统计的结果全部是亏空(盈利-亏空<0) ...

  7. [POJ2586]Y2K Accounting Bug

    [POJ2586]Y2K Accounting Bug 试题描述 Accounting for Computer Machinists (ACM) has sufferred from the Y2K ...

  8. POJ2586——Y2K Accounting Bug

    Y2K Accounting Bug   Description Accounting for Computer Machinists (ACM) has sufferred from the Y2K ...

  9. Y2K Accounting Bug(贪心)

    Y2K Accounting Bug Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10945   Accepted: 54 ...

随机推荐

  1. Qt自定义控件大全(一)云台仪表盘控件

    做过安防视频监控的同学都清楚,在视频监控系统软件上都可以看到一个云台控制区域,可以对球机进行下下左右等八个方位的运动控制,还可以进行复位,一般都是美工作图好,然后贴图的形式加入到软件中,好处是程序简单 ...

  2. MySQL对数据表进行分组查询(GROUP BY)

    MySQL对数据表进行分组查询(GROUP BY) GROUP BY关键字可以将查询结果按照某个字段或多个字段进行分组.字段中值相等的为一组.基本的语法格式如下: GROUP BY 属性名 [HAVI ...

  3. [sharepoint]Office Web Apps for SharePoint 2010

    Office Web Apps for SharePoint 2010 2012年09月20日 ⁄ 综合 ⁄ 共 908字 ⁄ 字号 小 中 大 ⁄ 评论关闭 After you install Of ...

  4. Pexpect学习:

    pexecpt run用法:格式:run(command,timeout=-1,withexitstatus=False,events=None,extra_args=None,logfile=Non ...

  5. jquery ajax中事件的执行顺序

    jquery中各个事件执行顺序如下: 1.ajaxStart(全局事件) 2.beforeSend 3.ajaxSend(全局事件) 4.success 5.ajaxSuccess(全局事件) 6.e ...

  6. Xcode - xcode-select: error: tool 'xcodebuild' requires Xcode报错解决方案

    用mac 自带的终端执行的命令,安装安装Vapor和toolbox 安装指令: macdeMacBook-Pro:~ mac$ curl -sL check.vapor.sh| bash 结果报这个错 ...

  7. CentOS7.5安装Tomcat8

    一.tomcat的简介 这是Apache Tomcat Servlet / JSP容器的文档包的顶级入口点 .的Apache Tomcat 8.0版实现了Servlet 3.1和JavaServer ...

  8. IIS7.5 配置虚拟目录的经历

    好多网站为了不带上什么端口号所有就建立虚拟目录的试来使用80端口 iis6设置都没有问题可到了7.5碰到了点问题 原来7.5上有个:添加应用程序和添加虚拟目录.还有个转换为应用程序 直接把网站建成虚拟 ...

  9. poj1269 intersecting lines【计算几何】

    We all know that a pair of distinct points on a plane defines a line and that a pair of lines on a p ...

  10. 计蒜客 31452 - Supreme Number - [简单数学][2018ICPC沈阳网络预赛K题]

    题目链接:https://nanti.jisuanke.com/t/31452 A prime number (or a prime) is a natural number greater than ...