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. Maven添加镜像仓库、更改本地仓库位置

    添加镜像仓库 在conf目录下的settings.xml文件的145行左右 id表示该镜像的id mirrorOf表示为哪个仓库配置镜像,central为默认的中央仓库的id,也可以使用通配符*,来匹 ...

  2. # 深圳杯D题爬取电视收视率排行榜

    目录 深圳杯D题爬取电视收视率排行榜 站点分析 代码实现 深圳杯D题爬取电视收视率排行榜 站点分析 http://www.tvtv.hk/archives/category/tv 每天的排行版通过静态 ...

  3. CVE-2018-20169漏洞学习

    简介 在4.19.9之前的Linux内核中发现了一个问题.USB子系统在读取与驱动程序/ USB /core/usb.c中的_usb_get_extra_descriptor相关的额外描述符时错误地检 ...

  4. Collection接口的子接口——Deque接口

    https://docs.oracle.com/javase/8/docs/api/java/util/Deque.html public interface Deque<E> exten ...

  5. Entity Framework Core Relationship的学习笔记

    说明 此例筛选了感兴趣及常用部分 参考文献 https://docs.microsoft.com/en-us/ef/core/modeling/relationships One to Many Ma ...

  6. JS代码格式化

    JS代码格式化也就是规范化,保留必要的换行和缩进使代码阅读起来更容易.团队协同工作时会有相应的标准,大家要保证统一的代码风格,这样在合并代码的时候才不容易出问题.通过快捷键Ctrl+Shift+F进行 ...

  7. Eclipse集成spring-tool-suite(STS)

    1.官方下载 sts是spring官方在eclipse基础上加了很多插件之后封装的开发工具.sts与eclipse完全一样,但是多了很多插件,比如maven,使用起来更加方便.如果使用eclipse自 ...

  8. wordcloud:让你的词语变成黑云

    介绍 对文本中出现频率较高的关键词给予视觉化的显示 使用 import jieba import codecs import wordcloud file = r"C:\Users\Admi ...

  9. D-query SPOJ - DQUERY (莫队算法裸题)

    Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query is a pair (i, j) ...

  10. javascript模板字符串(标签函数)

    前面介绍了javascript的模板字符串的基本知识,今天深入学习一下标签函数 模板字符串概述 这里先简单说一下模板字符串的概念 1.模板字符串,从名字上可以得出其实返回的是字符串,普通使用其实就想引 ...