C. The Big Race
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Vector Willman and Array Bolt are the two most famous athletes of Byteforces. They are going to compete in a race with a distance of L meters today.

Willman and Bolt have exactly the same speed, so when they compete the result is always a tie. That is a problem for the organizers because they want a winner.

While watching previous races the organizers have noticed that Willman can perform only steps of length equal to w meters, and Bolt can perform only steps of length equal to b meters. Organizers decided to slightly change the rules of the race. Now, at the end of the racetrack there will be an abyss, and the winner will be declared the athlete, who manages to run farther from the starting point of the the racetrack (which is not the subject to change by any of the athletes).

Note that none of the athletes can run infinitely far, as they both will at some moment of time face the point, such that only one step further will cause them to fall in the abyss. In other words, the athlete will not fall into the abyss if the total length of all his steps will be less or equal to the chosen distance L.

Since the organizers are very fair, the are going to set the length of the racetrack as an integer chosen randomly and uniformly in range from 1 to t (both are included). What is the probability that Willman and Bolt tie again today?

Input

The first line of the input contains three integers t, w and b (1 ≤ t, w, b ≤ 5·1018) — the maximum possible length of the racetrack, the length of Willman's steps and the length of Bolt's steps respectively.

Output

Print the answer to the problem as an irreducible fraction . Follow the format of the samples output.

The fraction (p and q are integers, and both p ≥ 0 and q > 0 holds) is called irreducible, if there is no such integer d > 1, that both p and q are divisible by d.

Examples
Input
10 3 2
Output
3/10
Input
7 1 2
Output
3/7
Note

In the first sample Willman and Bolt will tie in case 1, 6 or 7 are chosen as the length of the racetrack.

题意:两个人赛跑,一个人步长为w,另一个为v,赛道长度为L,跑的距离大于L时将掉入深渊.问在[1,t]范围内有多少个L使得这两个人无法分出胜负(同时落入深渊,或同时到达终点)

题解:循环节为lcm(w,v), 在每个循环节内 只有min(w,v)-1个同时掉入深渊 1个同时到达终点

由于lcm(w,v) 会爆__int64,我们可以用double暂存.

gg考虑的是最后一个循环节或不足一个循环节的部分

 /******************************
code by drizzle
blog: www.cnblogs.com/hsd-/
^ ^ ^ ^
O O
******************************/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#define ll __int64
#define mod 1000000007
#define PI acos(-1.0)
using namespace std;
ll t,w,b;
ll minx;
ll ans;
ll gg;
double zha;//注意开double
int main()
{
scanf("%I64d %I64d %I64d",&t,&w,&b);
minx=min(w,b);
zha= (double)(w/__gcd(w,b))*b;
ans=t/zha;
gg=(minx-)-(t-zha*ans);
ans=ans+(ans+)*(minx-);
if(gg>)
printf("%I64d/%I64d\n",(ans-gg)/__gcd(ans-gg,t),t/__gcd(ans-gg,t));
else
printf("%I64d/%I64d\n",ans/__gcd(ans,t),t/__gcd(ans,t));
return ;
}

最新文章

  1. 64位.net调用32位com服务(c++)
  2. JS 正则表达式中的特殊字符
  3. 小甲鱼PE详解之基址重定位详解(PE详解10)
  4. 如何创建一个自己的【Composer/Packagist】包
  5. C++必备知识
  6. 关于CH340在STM32实现一键下载电路的研究(转)
  7. Android_65535问题的解决
  8. 实践 Network Policy - 每天5分钟玩转 Docker 容器技术(172)
  9. 你注意到 .Net Framework 和 .Net Core 中使用 Session 的区别了吗?
  10. 20165311《网络对抗技术》Exp1 PC平台逆向破解
  11. golang 安装tensorflow
  12. chrome浏览器被reimage pair 劫持怎么处理
  13. vue--显示和隐藏
  14. npm 安装 cannot find module
  15. [EWS]查找 文件夹
  16. TextBox(只允许输入字母或者数字)——重写控件
  17. Radius 中 与Response Authernticator 与 Message-Authenticator的计算
  18. 最小圆覆盖 gym-102006 I
  19. python测试开发django-10.django连接mysql
  20. CodeForces 811B Vladik and Complicated Book

热门文章

  1. Docker自学纪实(四)搭建LNMP部署wordpress
  2. Fiddler(二)
  3. dts--framework(三)
  4. acm总结
  5. 奇异值分解(SVD)原理详解及推导
  6. 从Wireshark看TCP连接的建立与关闭
  7. 110Balanced Binary Tree
  8. long转int
  9. python基础&mdash;&mdash;数字&amp;集合&amp;布尔类型
  10. PQFitness