题意: 有一个公司由于某个病毒使公司赢亏数据丢失,但该公司每月的 赢亏是一个定数,要么一个月赢利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. thinkphp 多对多关联模型(转)

    先建立一个模型 1 2 3 4 5 6 7 8 9 10 11 12 <?php  class UserModel extends RelationModel{      protected $ ...

  2. VC++生成不同的随机数

    其用法是先调用srand函数,如 srand( (unsigned)time( NULL ) ) 这样可以使得每次产生的随机数序列不同.假如计算伪随机序列的初始数值(称为种子)相同,则计算出来的伪随机 ...

  3. jQuery().end()的内部实现及源码分析

    jQuery().end()的作用是返回当前jQuery对象的上一个状态. 1.end()源码: // 所有通过pushStack方法获得的jQuery对象都可以通过end方法返回之前的状态   // ...

  4. 使用mimikatz获取和创建Windows凭据的工具和方法

    Mimikatz 下载地址 https://github.com/gentilkiwi/mimikatz/releases 本地凭据破解 以管理员身份运行(拿到shell提权后) mimikatz#p ...

  5. [转]了解如何通过reverse_iterator的base得到iterator

    转自:http://blog.csdn.net/shuchao/article/details/3705252 调用reverse_iterator的base成员函数可以产生“对应的”iterator ...

  6. C# 日志系统 log4net 配置及使用

    1.引用Dll 版本是:1.2.10.0,下载Dll 2.Web.config文件配置 <?xml version="1.0" encoding="utf-8&qu ...

  7. Android 简单计算器实现源码

    1.string.xml代码 <?xml version="1.0" encoding="utf-8"?> <resources> &l ...

  8. express运行原理

    一.express底层:http模块 Express框架建立在node.js内置的http模块上.http模块生成服务器的原始代码如下. var http = require("http&q ...

  9. Olivia Palermo & Johannes Huebl 模范情侣

    男才女貌,模范情侣-- 以后引用情侣时就用这个图了~ ref: http://bbs.55bbs.com/thread-8250584-1-1.html

  10. codeforces 779D - String Game

    time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standa ...