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. 小记---------spark优化之更优分配资源

      spark优化:在一定范围之内,增加资源与性能的提升是成正比的. 因此,       一个cpu core  执行一个task线程. task数: 若有 cpu core 2个.num-execu ...

  2. 说一下redis中5种数据类型的底层数据结构

      前言: 阅读 redis设计与实现 一书的记录.未完待续... redis我们都知道有5种数据类型,分别是string,list,hash,set,zset,那么你知道它们的底层数据结构实现吗? ...

  3. C++练习 | 类的继承与派生练习(1)

    #include <iostream> #include <cmath> #include <cstring> #include <string> #i ...

  4. 矩阵快速幂(Matrix_Fast_Power)

    一.基础知识(1)矩阵乘法 https://blog.csdn.net/weixin_43272781/article/details/82899737 简单的说矩阵就是二维数组,数存在里面,矩阵乘法 ...

  5. leetcode难题

    4 寻找两个有序数组的中位数       35.9% 困难     10 正则表达式匹配       24.6% 困难     23 合并K个排序链表       47.4% 困难     25 K ...

  6. FastDFS集群部署(转载 写的比较好)

    FastDFS集群部署   之前介绍过关于FastDFS单机部署,详见博文:FastDFS+Nginx(单点部署)事例 下面来玩下FastDFS集群部署,实现高可用(HA) 服务器规划: 跟踪服务器1 ...

  7. LeetCode——回文链表

    题目 给定一个链表的头节点head,请判断该链表是否为回 文结构. 例如: 1->2->1,返回true. 1->2->2->1,返回true. 15->6-> ...

  8. 精确率与回召率与 F1-Meature

    例子: true positive(真正例): 把 Colin power预测为Colin power(55) false positive(假正例): 把 其他人预测为Colin power(4+1 ...

  9. 使用CXF开发WebService程序的总结(七):Spring+CXF+Mybatis+Mysql共同打造的服务端示例

    通过该demo,可以 熟悉下 spring+cxf+maven+mybatis+mysql等常见后端技术整合 1. 在前面的 父工程 ws_parent 中 添加依赖 由于原来的项目是使用的cxf依赖 ...

  10. Nginx做代理路由时,不转发http的header问题

    从header里面拿不到 TX_XID这种类型的字段, Nginx 会默认忽略含有 “_” 的 header 参数,而 TX_XID值的参数名恰好含有 “_” 符号,需要手动开启转发. 在 nginx ...