这次只做了A,B俩题竟然没掉rating,amazing,而且A题忘记特判被别人黑了,交了俩发再次AC。
A题注意特判,相等的情况,由于是A先,所以相等的时候是A赢,读了题竟然忘记了。
B题乱猜的,写了几个发现是(n-2)^2,然后就交了,最后答案规律竟然真的是这个,然而并不能说明白为什么。
C题其实也很简单,主要我竟然没有看出求LCM会乘法溢出。乘法溢出这里只要把公式变形一下特判下就行了。
贴下C题代码。本弱渣并没有看D题和E题,略过。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<climits>
#include<vector>
#include<cfloat>
#include<queue>
#include<cctype>
#include<cstdlib>
#include<string>
#define LL long long
using namespace std;
LL gcd(LL a,LL b)
{
return b?gcd(b,a%b):a;
}
int main()
{
LL t,w,b;
while(cin>>t>>w>>b)
{
if(w>b)
swap(w,b);
LL tem=gcd(w,b);
LL ans;
if(t/w*tem/b>0)
{
LL lcm=b/tem*w;
ans=t/lcm*w+min(t%lcm,w-1);
}
else
ans=min(w-1,t);
LL tem1=gcd(ans,t);
cout<<ans/tem1<<'/'<<t/tem1<<endl;
}
return 0;
}