[URI ONLINE JUDGE] – 2068 – Setting up a Date

Taynder is a very popular app. This app is used to meet new people, have relationships and set up dates. It was on Taynder that Mel and Tob met.

Mel and Tob already chatted for more than 40 minutes, so they think it’s time to know each other in person, they set up a date in the city main square. The only problem is that they didn’t define a exact time to the meeting, they only know the time interval that they are supposed to meet, but they don’t know when the other will arrive. So who gets there first waits a predefined time, but if no one arrives the person goes home to meet someone else in Taynder.

An example: if Mel and Tob will meet in the real interval [16h, 17h] with maximum wait time equals to 15 minutes, it means that Mel and Tob can arrive at any time between 16h and 17h (including 16h and 17h), and who gets there first, in the time x for instance, will wait for the other person in the time interval defined by [x, x + 15].

Your work is to write a program that, given the time interval of the meeting and the maximum wait time, determines the probability that they’ll meet.

Input

Each test case is an unique line with 3 integers: t1t2N.

t1and t2 represent the real time interval in hours such that t2 > t1 and 1 ≤ t1t2 ≤ 10⁶, N represents the maximum wait time in minutes such that 1 ≤ N ≤ (t2t1)*60.

Output

The output must be the probability of the date happens in the format a/b, such that a/b is an irreducible fraction.

Input Samples Output Samples
1 2 15 7/16
1 2 60 1/1

 

solution:

 

<br />#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
ll x1, x2, n;
cin >> x1 >> x2 >> n;
ll in = (x2 - x1) * 60LL;

ll sum = in * in;
ll en = sum - (in - n) * (in - n);

printf("%lld/%lld\n", en/__gcd(en, sum), sum/__gcd(en, sum));

return 0;
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s