标签:
Description
Input
Output
Sample Input
input | output |
---|---|
10000 5000 1000 3 50 |
Cash 500.00 |
15000 2500 1000 4 25 |
Insurance 10000.00 |
#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的写法,long long处理精度时需要将相除改成相乘,但是long long 基本不会错
暑假集训 #2 div1 I - Lada Priora 精度处理
标签:
原文地址:http://www.cnblogs.com/smilesundream/p/5664825.html