开O2 0pts是因为```oula()```没有返回值
by do_while_true @ 2021-03-26 15:55:01
不知道为啥你的常数这么大...我写的暴力求你代码里的F跑的挺快的,你可以改成线筛F
by do_while_true @ 2021-03-26 15:56:33
@[do_while_true](/user/223298) 人傻常熟大/yun/kk
by Tarsal @ 2021-03-26 15:57:31
@[do_while_true](/user/223298) 开个o2救过了/kk/拜谢
by Tarsal @ 2021-03-26 15:58:45
@[Tarsal](/user/155767)
```#define int long long``` 改掉,跑的就很快了
```cpp
#include <bits/stdc++.h>
using namespace std;
#define ls (x << 1)
#define rs (x << 1 | 1)
#define mid ((l + r) >> 1)
#define ll long long
#define Rep(x, a, b) for(int x = a; x <= b; ++ x)
#define Dep(x, a, b) for(int x = a; x >= b; -- x)
#define Next(i, x) for(int i = head[x]; i ; i = e[i].nxt)
int read() {
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
const int maxn = 1e7 + 10;
const int XRZ = 999911658;
int cnt, Mu[maxn], vis[maxn], Prime[maxn];
void oula(int n) {
Mu[1] = 1;
Rep(i, 2, n) {
if(vis[i] == 0) Mu[i] = -1, Prime[++ cnt] = i;
for(int j = 1; j <= cnt && i * Prime[j] <= n; ++ j) {
vis[Prime[j] * i] = 1;
if(i % Prime[j] == 0) break;
Mu[Prime[j] * i] = -Mu[i];
}
}
} int F[maxn], sum[maxn];
signed main() {
oula(maxn - 10);
Rep(i, 1, cnt) for(int j = 1; j * Prime[i] <= maxn - 10; ++ j) F[j * Prime[i]] += Mu[j];
Rep(i, 1, maxn - 10) sum[i] = sum[i - 1] + F[i];
int T = read();
while(T --) {
int l = read(), r = read(); ll ans = 0;
if(l > r) swap(l, r);
for(int i = 1, j; i <= l; i = j + 1) {
j = min(l / (l / i), r / (r / i));//取2个块下一个的最小值,整数分块。
ans += 1ll * (l / i) * (r / i) * (sum[j] - sum[i - 1]);
} printf("%lld\n", ans);
}
return 0;
}
```
by do_while_true @ 2021-03-26 15:59:46
@[do_while_true](/user/223298) 谢谢
by Tarsal @ 2021-03-26 16:49:00