H. Huashui Clock

#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long int h,m,r,x,y,a,z,b,l,k;
    while(cin>>h>>m&&h&&m)
    {
        if(h==m||h>m)
        {
            x=(m+1)*m/2;
            y=h*m;
            k=x;
            l=y;
        }
        else
        {
            x=h*m-(h-1)*h/2;
            y=h*m;
            k=x;
            l=y;
        }
    while (x!= 0)

	{
		z = y%x;
		y=x;
		x=z;
        a=y;
	}
       cout<<k/a<<"/"<<l/a<<endl;
    }
}

For those who don’t speak Chinese, huashui may not even be a legitimate word for you. You don’t have to know what it is to solve this problem, but to make everything clear, huashui refers to the status of not working, especially at working hours. Some people decide to make some plans on when to work, and when to huashui. So they invent a lockscreen app with a built-in clock. This clock is just like any other usual clock, except that it has h hours a day and m minutes an hour. Indicator of seconds is not displayed in the app, so you can safely ignore 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, this minute 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 integers h and m (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. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值