用户输出
2
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#45692 | #1243. zxh的高等数学 | Accepted | 100 | 2845 ms | 388 K | C++ / 1.6 K | iNx | 2020-08-03 17:36:49 |
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
namespace iNx {
typedef __int128_t LL;
const LL MOD = 998244353;
inline LL read() {
LL k = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') k = k * 10 + ch - '0', ch = getchar();
return k * f;
}
inline void write(LL x) {
if (x < 0)
x = -x, putchar('-');
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
LL f_pow(LL a, LL b, LL mod) {
LL res = 1, base = a;
while (b) {
if (b & 1)
res = (res * base) % mod;
base = (base * base) % mod;
b >>= 1;
}
return res;
}
LL n, ans;
void work() {
n = read();
LL i, tmp, a, k;
for (i = 2; i * i <= n; i++) {
a = i, k = 0, tmp = 0;
while (a < n) {
++k;
tmp = (tmp - a) % MOD;
a *= i;
}
tmp = (tmp + k * (n + 1)) % MOD;
ans = (ans + tmp * i % MOD) % MOD;
}
LL inv2 = f_pow(2, MOD - 2, MOD), inv6 = f_pow(6, MOD - 2, MOD);
ans = (ans + (n + 1) * (i + n) % MOD * (n - i + 1) % MOD * inv2 % MOD) % MOD;
ans = (ans - n * (n + 1) % MOD * (2 * n + 1) % MOD * inv6 % MOD) % MOD;
ans = (ans + (i - 1) * i % MOD * (2 * i - 1) % MOD * inv6 % MOD) % MOD;
write((ans + MOD) % MOD);
puts("");
}
} // namespace iNx
int main() {
iNx::work();
return 0;
}