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 ;
}

Codeforces Round #328 (Div. 2) C 数学的更多相关文章

  1. Codeforces Round #328 (Div. 2) C. The Big Race 数学.lcm

    C. The Big Race Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/probl ...

  2. Codeforces Round #328 (Div. 2) B. The Monster and the Squirrel 打表数学

    B. The Monster and the Squirrel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/c ...

  3. Codeforces Round #328 (Div. 2)

    这场CF,准备充足,回寝室洗了澡,睡了一觉,可结果...   水 A - PawnChess 第一次忘记判断相等时A先走算A赢,hack掉.后来才知道自己的代码写错了(摔 for (int i=1; ...

  4. Codeforces Round #328 (Div. 2) D. Super M

    题目链接: http://codeforces.com/contest/592/problem/D 题意: 给你一颗树,树上有一些必须访问的节点,你可以任选一个起点,依次访问所有的必须访问的节点,使总 ...

  5. Codeforces Round #328 (Div. 2) D. Super M 虚树直径

    D. Super M Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/D ...

  6. Codeforces Round #328 (Div. 2) A. PawnChess 暴力

    A. PawnChess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/592/problem/ ...

  7. Codeforces Round #372 (Div. 2) C 数学

    http://codeforces.com/contest/716/problem/C 题目大意:感觉这道题还是好懂得吧. 思路:不断的通过列式子的出来了.首先我们定义level=i, uplevel ...

  8. A. Little C Loves 3 I Codeforces Round #511 (Div. 2) 【数学】

    题目: Little C loves number «3» very much. He loves all things about it. Now he has a positive integer ...

  9. Codeforces Round #549 (Div. 2) D 数学

    https://codeforces.com/contest/1143/problem/D 题意 有nk个城市,第1,k+1,2k+1,...,(n-1)k+1城市有餐厅,你每次能走l距离,a为起始位 ...

随机推荐

  1. MySQL5.6基于mysql-proxy实现读写分离

    已经搭建好MySQL主从架构 10.205.22.185 #mysql-proxy 10.205.22.186 #master 10.205.22.187 #slave 1.安装mysql-proxy ...

  2. pywinauto 的使用

    要用python实现Windows窗口程序的自动化操作,可以用ctypes调用windowsapi来实现,还可以用pywin32+pywinauto来实现,后者是别人造的轮子. pywinauto首页 ...

  3. git push 时 fatal: Unable to create 'D:/phpStudy/WWW/green_tree/.git/index.lock': File exists.解决办法

    找到自己的项目,找到.git文件夹,进去把目标文件删除即可 或者使用rm -rf 命令(如果没有那个文件件或者文件,将隐藏文件打开就可以看到了)

  4. PHP CI框架学习

    CI框架的URL辅助函数使用 URL 辅助函数文件包含一些在处理 URL 中很有用的函数 加载辅助函数 在使用CI框架的使用经常碰到跳转和路径方面的问题,site_url()和base_url()很容 ...

  5. Choosing Capital for Treeland CodeForces - 219D (树形DP)

    传送门 The country Treeland consists of n cities, some pairs of them are connected with unidirectional  ...

  6. HDU 5446 Unknown Treasure (卢卡斯+CRT

    代码: #include"bits/stdc++.h" #define db double #define ll long long #define vec vector<l ...

  7. 如何使用Python脚本

    来自官方文档 一.写 python 脚本: import sys import datetime for line in sys.stdin: line = line.strip() userid, ...

  8. FIFO页面淘汰算法

    1.优异虚拟存储系统,若进程在内存中占3页(开始时内存为空),若采用先进先出(FIFO)页面淘汰算法,当执行以下访问页号序列后1,3,4,2,1,3,5,1,2,5,4,2,会产生多少次缺页(9) 在 ...

  9. jQuery上传文件控件Uploadify使用

    Uploadify是JQuery的一个上传插件,支持ajax无刷新上传,多个文件同时上传,上传进行进度显示,删除已上传文件等. 首先应下载jQuery和uploadify插件 jQuery下载地址:h ...

  10. 剑指Offer - 九度1355 - 扑克牌顺子

    剑指Offer - 九度1355 - 扑克牌顺子2014-01-30 23:19 题目描述: LL今天心情特别好,因为他去买了一副扑克牌,发现里面居然有2个大王,2个小王(一副牌原本是54张^_^). ...