CF1967D2 补题笔记
批:赛时没想到
首先经典套路,设
两边同除
由
由于
于是就成功地缩小了
code
//writer:Oier_szc
#include <bits/stdc++.h>
//#include <windows.h>
#define ED cerr<<endl;
#define TS cerr<<"I AK IOI"<<endl;
#define cr(x) cerr<<x<<endl;
#define cr2(x,y) cerr<<x<<" "<<y<<endl;
#define cr3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<endl;
#define cr4(x,y,z,w) cerr<<x<<" "<<y<<" "<<z<<" "<<w<<endl;
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
using namespace std;
const int N=2e3+5,INF=2e9,mod=1e9+7;
int t,n,m;
int bad[N][N];
int gcd(int a,int b) {return !b?a:gcd(b,a%b);}
signed main() {
scanf("%lld",&t);
while(t--) {
scanf("%lld%lld",&n,&m);
int ans=0;
for(int a=1;a<=n/a;++a) {
for(int b=1;b<=m/b;++b) {
if(gcd(a,b)==1) ans+=min(n/a,m/b)/(a+b);
}
}
printf("%lld\n",ans);
}
return 0;
}