I - Lada Priora

Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Winter in Yekaterinburg is the longest time of the year. And everyone spends long winter evenings in his own way. Max loves to drive through the city on his toned Lada Priora with lowered suspension. And nothing can stop him, neither snow nor ice. Well, except that a lamppost or a bus stop. Or, as today, the bumper of a black Mercedes with four strong guys inside that are not very happy with a bucket of bolts flown into their car. Now Max has a difficult choice. He can pay immediately for damage, not making the issue of an accident. Fortunately, Mercedes is the durable car, and all its damage is just a few scratches. Or Max can call the traffic police to register the accident as it should be. In this case, his insurance company will pay for the damage. In the second case the cost of insurance for Max in the next few years will be higher. Because Max calculates not so good, and the guys from Mercedes are already worried, he has called you to ask which of these two options is more advantageous for him.
This year, Max pays for the insurance c rubles. If he does not register the accident, then the next year he will pay c + d rubles, then c+ 2 d rubles, and so on, each following year the cost of insurance will rise d rubles. If he registers the accident, then for k years, starting from the next one, Max will have to pay for insurance p percent more. So the next year he will pay ( c + d) · (1 + p/100) rubles, then ( c + 2 d) · (1 + p/100) rubles, and so on.

Input

The first line contains an integer b that is the amount of money in rubles, which Max can pay the driver of the Mercedes, without registering the accident (1 ≤ b ≤ 10 5). The second line contains the integers c and d that are current insurance cost in rubles and how many rubles it increases every year if not to get into an accident (1 ≤ cd ≤ 10 4). The third line contains integers k and p meaning how many years Max will have to buy more expensive insurance, and what percent its cost is higher than the cost of an usual insurance (1 ≤ kp ≤ 100).

Output

If it is more advantageous for Max not to register the accident, then output in the first line “Cash”, otherwise output in the first line “Insurance” (including the case, if both options are equally disadvantageous). In the second line output the amount of money in rubles, that show how more advantageous your choice than the other one. The answer should be given with absolute or relative error not exceeding 10 −6.

Sample Input

input output
10000
5000 1000
3 50
Cash
500.00
15000
2500 1000
4 25
Insurance
10000.00

Notes

In the first example, the cost of insurance for the next three years is 21 000 rubles, if not to register the accident, and 31 500 rubles, if to register it.
In the second example, the cost of insurance for the next four years is 20 000 rubles, if not to register the accident, and 25 000 rubles, if to register it.
题意:一个人有两种付钱方式,第一种是先付一定数目的钱,然后第i年付c+i*d的钱
需要付费k年,另外一种是每年直接付费(c+i*d)(1+p/100)的钱,问选择哪种方式使得
付的钱最少。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std; int main()
{
long long b,c,d,k,p;
while(~scanf("%lld",&b))
{
scanf("%lld %lld",&c,&d);
scanf("%lld %lld",&k,&p);
long long tot=0;
for(int i=1;i<=k;i++) tot+=(c+i*d);
tot*=p;
if(tot>100*b) printf("Cash\n%.13f\n",tot/100.0-b);
else printf("Insurance\n%.13f\n",b-tot/100.0);
}
return 0;
}

分析:题目很简单,但是精度卡起来很变态,double被卡死了。只好采用大神们的
换成long long的写法,(因为double在进行if判断的时候可能会掉精度)long long处理精度时需要将相除改成相乘,但是long long 基本不会错

暑假集训 #2 div1 I - Lada Priora 精度处理的更多相关文章

  1. 暑假集训#2 div1 J 四点直角 J - Space Invader 四点共面+跨立实验

    题意:给你四个点,判断能否先依次通过A,B两点,然后再在某个地方只进行一次直角转弯再一次经过C,D两点: #include <iostream> #include <cstdio&g ...

  2. 2015UESTC 暑假集训总结

    day1: 考微观经济学去了…… day2: 一开始就看了看一道题目最短的B题,拍了半小时交了上去wa了 感觉自己一定是自己想错了,于是去拍大家都过的A题,十分钟拍完交上去就A了 然后B题写了一发暴力 ...

  3. STL 入门 (17 暑假集训第一周)

    快速全排列的函数 头文件<algorithm> next_permutation(a,a+n) ---------------------------------------------- ...

  4. 暑假集训Day2 互不侵犯(状压dp)

    这又是个状压dp (大型自闭现场) 题目大意: 在N*N的棋盘里面放K个国王,使他们互不攻击,共有多少种摆放方案.国王能攻击到它上下左右,以及左上左下右上右下八个方向上附近的各一个格子,共8个格子. ...

  5. 暑假集训Day1 整数划分

    题目大意: 如何把一个正整数N(N长度<20)划分为M(M>=1)个部分,使这M个部分的乘积最大.N.M从键盘输入,输出最大值及一种划分方式. 输入格式: 第一行一个正整数T(T<= ...

  6. 暑假集训 div1 B Derangement 交换数字 思维死角

    B. Derangement time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  7. 2013ACM暑假集训总结-致将走上大三征途的我

    回想起这个暑假,从开始与雄鹰一起的纠结要不要进集训队,与吉吉博博组队参加地大邀请赛,害怕进不了集训队.当时激励我月份开始接触的,记得当时在弄运动会来着,然后就问了雄鹰一些输入输出的东西,怀着满心的期待 ...

  8. [补档]暑假集训D5总结

    %dalao 今天又有dalao来讲课,讲的是网络流 网络流--从入门到放弃:7-29dalao讲课笔记--https://hzoi-mafia.github.io/2017/07/29/27/   ...

  9. [补档]暑假集训D1总结

    归来 今天就这样回来了,虽然心里极其不想回来(暑假!@#的只有一天啊喂),但还是回来了,没办法,虽然不喜欢这个地方,但是机房却也是少数能给我安慰的地方,心再累,也没有办法了,不如好好集训= = %da ...

随机推荐

  1. CSP 字符串匹配(201409-3)

    问题描述 给出一个字符串和多行文字,在这些文字中找到字符串出现的那些行.你的程序还需支持大小写敏感选项:当选项打开时,表示同一个字母的大写和小写看作不同的字符:当选项关闭时,表示同一个字母的大写和小写 ...

  2. java检测是不是移动端访问

    request可以用别的代替 private static boolean isMobile(){ HttpServletRequest request = ThreadContextHolder.g ...

  3. 如何用纯 CSS 创作一个菜单反色填充特效

    效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览.https://codepen.io/comehope/pen/qYMoPo 可交互视频教程 ...

  4. Java小程序—录屏小程序(下半场)

    下半场. 上半场,我们我们写了录屏的程序,那么下半场我们的任务是写一个播放器. 设计思路:播放器的思路就是将图片放在一个JScrollPane中顺序播放,所以还是得使用swing组件,并且仍然要使用线 ...

  5. Codeforces 1201C. Maximum Median

    传送门 看到中位数考虑先把数排序一下 然后有个显然的贪心,一个数增加后一定不能比下一个数大,不然我们直接增加下一个数显然更优 所以初始时的中位数操作后也是中位数 那么我们只要考虑中间再往后怎么加使得答 ...

  6. mysql复习(2)

    一.数据定义: SQL数据的定义包括模式的定义.表定义.视图定义和索引的定义. 1.基本的模式定义情况如下表. 2.一个关系数据库管理系统的实例中可以创建多个数据库,一个数据库中可以建立多个模式,一个 ...

  7. node.js学习之路(1)

    node.js 属于后台语言,后台语言还有php,java等. 优势:1.性能好   node.js VS php   86倍 2.跟前台JS配合方便 3.node.js便于前端学习 https:// ...

  8. jQuery效果--隐藏和显示

    jQuery hide() 和 show() 通过 jQuery,您可以使用 hide() 和 show() 方法来隐藏和显示 HTML 元素: $("#hide").click( ...

  9. 使用 java 创建你的第一个区块链(第二部分)

    本系列教程的目的是帮助您了解如何开发区块链技术. 在这第二个教程中,我们将: 创建一个简单的钱包: 使用我们的区块链发送已签名的交易: 感觉更酷. 以上这些将使我们拥有自己的加密货币! 从上一个教程开 ...

  10. CentOS 7系统时间与实际时间差8个小时

    1.查看系统时间: [root@localhost sysconfig]# timedatectl Local time: 一 2017-11-06 21:13:19 CST Universal ti ...