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 基本不会错

最新文章

  1. mac下使用sencha cmd+extjs6
  2. HTML5移动Web开发(七)——通过界面图标启动Web应用
  3. Codeforces 259 B - Little Pony and Sort by Shift
  4. ios - 文件保存路径的获取
  5. 【转】对 Xcode 菜单选项的详细探索(干货)
  6. Installation error INSTALL_FAILED_VERSION_DOWNGRADE错误
  7. java基础(十八)IO流(一)
  8. java基础知识再学习--maven
  9. 推荐5个漂亮的网站html源码
  10. System.Web.Caching.Cache 方法汇总
  11. HTML文档及标签介绍
  12. HTML友情链接代码
  13. Project Euler:Product-sum numbers (problem 88) C++
  14. 【iOS】Swift类的继承、构造方法、析构器等复习
  15. 技术文档分享_linux中生成考核用的GPT分区表结构修复
  16. 使用paginate分页后数据处理
  17. QT 窗口拖拽移动实现
  18. hdoj1004(查找众多字符串中个数最多的字符串)
  19. 各大APP注册时发送短信验证码是怎么实现的?
  20. x86 TargetPlatform with XBAPs

热门文章

  1. mysql 错误号码1129
  2. Maximum XOR Sum 系列问题
  3. UOJ46 玄学
  4. windows terminal编译实录
  5. L2-013. 红色警报(并查集+无向图联通分量)
  6. Linux: cp 复制文件、文件夹到文件夹
  7. 枚举类型C语言规律用法总结
  8. bash脚本测试总结
  9. 谈谈对this的指向问题
  10. 防范DDoS攻击的15个方法