首页 > 代码库 > ZOJ 3600 Taxi Fare

ZOJ 3600 Taxi Fare

一道水题 因为精度卡了半天 也是醉了= =

 

#include<cstdio>#include<cstring>#include<stdlib.h>#include<algorithm>#include<iostream>#include<math.h>using namespace std;int main(){    int kase;    cin>>kase;    while(kase--)        {            int n,t;            scanf("%d%d",&n,&t);            float ansa,ansb;            if(n<=3)            {                ansa=11;                ansb=11;            }            else if(3<n&&n<=10)            {                ansa=(n-3)*2.0;                ansb=(n-3)*2.5;            }            else            {                ansa=14+(n-10)*3.0;                ansb=17.5+(n-10)*3.75;            }            float  ta,tb;            ta=2.0/5;            tb=2.5/4;            ta=t*ta;            tb=t*tb;            ansa+=ta;            ansb+=tb;            int aa=(int)(ansa+0.5);//费用向上进位             int bb=(int)(ansb+0.5);            printf("%d\n",bb-aa);        }    return 0;}