http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3600
Main topic:
Hangzhou has two kinds of taxi prices, one is three kilometers within 10 yuan, 3~10 kilometers per kilometer of 2 yuan, more than 10 kilometers of the portion of 3 yuan per kilometer, 5 minutes per hour, the need for 2 yuan, but additional pay 1 yuan. Another is three kilometers within 11 yuan, 3~10 kilometers per kilometer of 2.5 yuan, more than 10 kilometers of the portion of 3.75 yuan per kilometer, each 4 minutes need 2.5 yuan. Ask how much money the first is cheaper than the second.
Problem Solving Ideas:
Follow the test instructions simulation again, pay attention to the accuracy problem.
#include <iostream>
#include <cstdio>
using namespace std;
int main ()
{
int tt,d,t;
cin>>tt;
while (tt--)
{
cin>>d>>t;
Double ans1=t*0.4+11,ans2=t*0.625+11;
if (d>3)
{
if (d<=10)
{
ans1+=2* (d-3);
ans2+=2.5* (d-3);
}
else
{
ans1+=14+3* (d-10);
ans2+=17.5+3.75* (d-10);
}
}
int ans= (int) (ans2+0.5)-(int) (ans1+0.5);
cout<<ans<<endl;
}
return 0;