Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98654 | CSYZTanXi | SUM | C++ | 运行超时 | 35 | 1000 MS | 264 KB | 913 | 2023-08-16 12:12:52 |
#include<bits/stdc++.h> #define int long long using namespace std; int gcd(int x,int y) { if(x==0) return y; return gcd(y%x,x); } int t; signed main() { // freopen("SUM.in","r",stdin); // freopen("SUM.out","w",stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>t; while(t--) { int l,r; cin>>l>>r; int ans=(r-l+1)*(r-l)*(r-l-1)/6; if(r-l+1>=3) { for(int i=l;i<=r;i++) { int now=0; for(int k=1;k*k<=i;k++) { if(i%k==0) { now+=2; if(k<l) now--; if(i/k<l) now--; if(k*k==i&&k>=l) now--; } } now--; ans-=now*(now-1)/2; } cout<<ans-max(0ll,r/15-(l-1)/6)-max(0ll,(r/6-(l-1)/3))<<'\n'; } else cout<<0<<'\n'; } return 0; }