Summer Camp #2 div1 I-lada priora Precision Processing

Source: Internet
Author: User

I-Lada PRiORATime limit:1000MS Memory Limit:65536KB 64bit IO Format:%i64d & Amp %i64u Submit Status Practice URAL 2098

Description

Winter in Yekaterinburg are the longest time of the year. And everyone spends long winter evenings in the his own. Max loves to drive through the city in his toned Lada priora with lowered suspension. And nothing can stop him, neither snow nor ice. Well, except a lamppost or a bus stop. Or, as today, the bumper of a black Mercedes with four strong guys inside that is not very happy with a bucket of bolts f Lown into their car. Now Max has a difficult choice. He can pay immediately to damage, not making the issue of a accident. Fortunately, Mercedes are the durable car, and all their damage is just a few scratches. Or Max can call the "Traffic police to register" the accident as it should be. In this case, he insurance company would pay for the damage. In the second case, the cost of insurance for Max in the next few years would be higher. Because Max calculates good, and the guys from Mercedes is already worried, he has called you to ask which of thes E-options are more advantAgeous for him. This year, Max pays for the insurance CRubles. If He does not register the accident and then the next year he'll pay C+ DRubles, then. C+ 2 DRubles, and so on, each following year the cost of insurance would rise  d  rubles. If He registers the accident, then For  k  years, starting from the next one, Max'll has to pay for Insurance  p  percent more. So the next year he'll 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 bThat's the amount of money in rubles, which Max can pay the driver of the Mercedes, without registering the accident (1≤ b≤105). The second line contains the integers Cand D that is current insurance cost in rubles and how many rubles it increases every Accident (1≤  c ,   d  ≤10  4). The third line contains Integers  k  and  p  meaning How many years Max'll has to buy more expensive insurance, and what percent its Co ST is higher than the cost of an usual insurance (1≤  k ,   p  ≤100).

Output

If It is more advantageous for Max does not register the accident and then output in the first line "Cash", otherwise output in The first line "Insurance" (including, if both options is equally disadvantageous). The second line output the amount for money in rubles, that's show how more advantageous your choice than the other one. The answer should is given with absolute or relative error not exceeding 10−6.

Sample Input

input Output
100005000 10003 50
Cash500.00
150002500 10004 25
Insurance10000.00
Notesin The first example, the cost of insurance for the next three years are rubles, if not to register the Acciden T, and rubles, if to register it. In the second example, the cost of insurance for the next four years are rubles, if not to register the accident, an D rubles, if to register it. Test instructions: A person has two ways to pay, the first is to pay a certain amount of money, and then I pay c+i*d money to pay for k years, and the other is the annual direct Pay (C+I*D) (1+p/100) Money, Ask which method you choose to make the least amount of money paid.
#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;}

Analysis: The topic is very simple, but the accuracy of the card is very abnormal, double was stuck. Had to adopt the great gods '
To the long long, long long processing precision needs to be divided into multiplication, but long long is basically not wrong

Summer Camp #2 div1 I-lada priora Precision Processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.