ZOJ 3600 Taxi Fare(数学啊)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4703

Last September, Hangzhou raised the taxi fares.

The original flag-down fare in Hangzhou was 10 yuan, plusing 2 yuan per kilometer after the first 3km and 3 yuan per kilometer after 10km. The waiting fee was 2 yuan per five minutes.
Passengers need to pay extra 1 yuan as the fuel surcharge.

According to new prices, the flag-down fare is 11 yuan, while passengers pay 2.5 yuan per kilometer after the first 3 kilometers, and 3.75 yuan per kilometer after 10km. The waiting fee
is 2.5 yuan per four minutes.

The actual fare is rounded to the nearest yuan, and halfway cases are rounded up. How much more money does it cost to take a taxi if the distance is d kilometers and the waiting
time is t minutes.

Input

There are multiple test cases. The first line of input is an integer T ≈ 10000 indicating the number of test cases.

Each test case contains two integers 1 ≤ d ≤ 1000 and 0 ≤ t ≤ 300.

Output

For each test case, output the answer as an integer.

Sample Input

4
2 0
5 2
7 3
11 4

Sample Output

0
1
3
5

Author: WU, Zejun

Contest: The 9th Zhejiang Provincial Collegiate Programming Contest

PS:

注意结果要四舍五入, 加个0.5 在强制转换就好了!

代码如下:

#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int main()
{
	int T,d,t,a,b;
	double sum1,sum2;
	while(cin >> T)
	{
		while(T--)
		{
			cin >> d >> t;
			sum1=11;
			sum2=11;
			if(d>3&&d<=10)
			{
				sum1+=(d-3)*2;
				sum2+=(d-3)*2.5;
			}
			else if(d>10)
			{
				sum1+=7*2+(d-10)*3;
				sum2+=7*2.5+(d-10)*3.75;
			}
			sum1+=(t/5.0)*2;
			sum2+=(t/4.0)*2.5;
			a=(int)(sum1+0.5);
			b=(int)(sum2+0.5);
			if(a>b)
				cout << a - b << endl;
			else
				cout << b - a << endl;
		}
	}
	return 0;
}
时间: 04-18

ZOJ 3600 Taxi Fare(数学啊)的相关文章

ZOJ 3156 Taxi (二分匹配+二分查找)

题目链接:Taxi Taxi Time Limit: 1 Second      Memory Limit: 32768 KB As we all know, it often rains suddenly in Hangzhou during summer time.I suffered a heavy rain when I was walking on the street yesterday, so I decided to take a taxi back school. I foun

ZOJ 3903 Ant(数学,推公示+乘法逆元)

Ant Time Limit: 1 Second      Memory Limit: 32768 KB There is an ant named Alice. Alice likes going hiking very much. Today, she wants to climb a cuboid. The length of cuboid's longest edge is n, and the other edges are all positive integers. Alice's

zoj.3868.GCD Expectation(数学推导&gt;&gt;容斥原理)

GCD Expectation Time Limit: 4 Seconds                                     Memory Limit: 262144 KB Edward has a set of n integers {a1, a2,...,an}. He randomly picks a nonempty subset {x1, x2,…,xm} (each nonempty subset has equal probability to be pick

ZOJ 3710 Friends(数学啊 )

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3710 Alice lives in the country where people like to make friends. The friendship is bidirectional and if any two person have no less than k friends in common, they will become friends

[三分法初探]

[Uva Error Curves]一些二次函数取max的交集还是一个下凸函数.三分即可 #include <bits/stdc++.h> #define maxn 10010 using namespace std; int n, a[maxn], b[maxn], c[maxn]; #define F(i, x) a[i] * x * x + b[i] * x + c[i] inline double cal(double x){ double ret = -1e12; for(int i

HDU 4791 &amp;amp; ZOJ 3726 Alice&amp;#39;s Print Service (数学 打表)

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5072 Problem Description Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her pr

HDU 4791 &amp; ZOJ 3726 Alice&#39;s Print Service (数学 打表)

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=4791 ZJU:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5072 Problem Description Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her pr

URAL 2005. Taxi for Programmers (最短路 数学啊)

题目链接:http://acm.timus.ru/problem.aspx?space=1&num=2005 2005. Taxi for Programmers Time limit: 0.5 second Memory limit: 64 MB The clock shows 11:30 PM. The sports programmers of the institute of maths and computer science have just finished their trai

HDU 1988 &amp; ZOJ 2991 Flipping Burned Pancakes(数学啊+模拟)

题目链接: HDU:http://acm.hdu.edu.cn/showproblem.php?pid=1988 ZOJ:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1990 Problem Description The cook at the Frobbozz Magic Pancake House sometimes falls asleep on the job while cooking pancakes. As