rt,这是昨晚 div1 B2/div2 D2 的代码,疑似玄学复杂度,但是过了(
#include<bits/stdc++.h>
using namespace std;
int n,T,m,ans;
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cin>>T;
while(T--){
cin>>n>>m,ans=0;
for(int s=2;s<=n;s++)
for(int g=s;g<=n;g+=s)
for(int x=max(1,s-m/g);x<=s&&x<=n/g;x++)
if(__gcd(x,s-x)==1)
ans++;
cout<<ans<<'\n';
}
return 0;
}
1≤∑n,∑m≤2×106