For those who don’t speak Chinese, huashui may not even be a legitimate word for you. You don’t haveto know what it is to solve this problem, but to make everything clear, huashui refers to the status ofnot working, especially at working hours.
Some people decide to make some plans on when to work, and when to huashui. So they invent alockscreen app with a built-in clock. This clock is just like any other usual clock, except that it hashhours a day andmminutes an hour. Indicator of seconds is not displayed in the app, so you can safelyignore that. Therefore the time display ranges from “0 : 0” to “h−1 :m−1”.
Well, the plan works like this: if the minute number is greater than or equal to the hour number, thisminute is a “huashui minute”; otherwise you are going to work.
You are a hard-worker, and you probably disdain the idea of this clock; but Donald, as a huashui-lover,is obsessed with this app and would very much like to know how much time in a day he can huashui.Help him calculate that and you will win a balloon.
Input
The only line of the input consists of two integershandm(2≤h, m≤109), with space between.
Output
Output huashui time divided by the length of time in a day in a reduced fraction form.
Example
Note
It would be interesting if you have got a “Wrong Answer” on this problem and did not do it on purpose.
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long h, m;
scanf("%lld %lld", &h, &m);
long long rex = 0, rey;
if(h>=m)
{
rex = (1+m)*m/2;
}
else rex = h*m-(h-1)*h/2;
rey = h*m;
long long re = __gcd(rex, rey);
printf("%lld/%lld\n", rex/re, rey/re);
return 0;
}