第一页第八篇 @Liuxizai 的题解,在下面数据生成器给出的数据下 TLE,测试用洛谷 IDE,语言 C++14 (GCC 9) O2。
#include <bits/stdc++.h>
using namespace std;
int main() {
puts("1000");
for(int i=1;i<=1000;i++)
puts("223092870");
return 0;
}
其中 223092870=2×3×5×7×11×13×17×19×23。
顺便提问:
当单点求 φ 时使用如下两种代码,则解法的时间复杂度是多少,具体怎么算?(式子最外面枚举约数是 O(n) 的暴力)
ll tmp = x;
for(ll i=2;i*i<=x;i++) {
if(!(x % i)) {
ans = ans / i * (i - 1);
while(!(x % i)) x /= i;
}
}