(给出数n,a,b)
(在[1,n]区间内随机选数,选出的数被a,b除后同余的概率)
(这题的精度问题真的是烦炸了~)
(设最小公倍数lcm=a*b/gcd(a,b))
(所以在区间[k*lcm,k*lcm+min(a,b)-1]都是同余的(k是常数))
(并且在区间[1,min(a,b)-1]也是同余的,然后模拟即可)
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
ll n,a,b,ans;
ll gcd(ll a,ll b){
if(!b) return a;
else return gcd(b,a%b);
}
int main()
{
cin>>n>>a>>b;
if(1.0*b/gcd(a,b)*a>(double)n)//直接算lcm会炸,比较一下
ans=min(n,min(a,b)-1);
else
{
ll lcm=a/gcd(a,b)*b;
ll k=n/lcm;
ans=k*min(a,b)+min(n%lcm,min(a,b)-1);
//其实是k*min(a,b)-1,因为第一个区间少了1,为了方便我们在后面部分减1
}
ll yinzi=gcd(n,ans);
cout<<ans/yinzi<<"/"<<n/yinzi;
return 0;
}