QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#702028 | #7046. Function! | Loxilante# | WA | 5ms | 3924kb | C++20 | 1.3kb | 2024-11-02 15:08:32 | 2024-11-02 15:08:34 |
Judging History
answer
#define F_C
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#endif
const int MOD = 998244353;
int quickPow(int a, int b)
{
int p = a, ans = 1;
while(b)
{
if (b&1) ans *= p, ans %= MOD;
p *= p; p %= MOD;
b >>= 1;
}
return ans;
}
int inv(int e)
{
return quickPow(e, MOD-2);
}
signed main(void)
{
#ifdef LOCAL
// freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
// freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
int n = next(), ans = 0;
for(int i = 2; i*i <= n; i++)
{
int p = log(n)/log(i), t = ((p-1)*quickPow(i, p)%MOD-(quickPow(i, p)-i)*inv(i-1)%MOD)%MOD+(n-quickPow(i, p)+1)%MOD*p%MOD;
ans += t%MOD*i%MOD;
}
int g = sqrt(n)+1;
// D(g, inv(2), inv(6));
ans += (g+n)%MOD*(n-g+1)%MOD*inv(2)%MOD*(n+1)%MOD-n%MOD*(n+1)%MOD*(2*n+1)%MOD*inv(6)%MOD+(g-1)*g%MOD*(2*g-1)%MOD*inv(6);
cout<<ans%MOD<<endl;
return 0;
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3924kb
input:
10
output:
236
result:
ok 1 number(s): "236"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
20
output:
1646
result:
ok 1 number(s): "1646"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
27
output:
3862
result:
ok 1 number(s): "3862"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
37
output:
9571
result:
ok 1 number(s): "9571"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
100
output:
175028
result:
ok 1 number(s): "175028"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3744kb
input:
123
output:
322744
result:
ok 1 number(s): "322744"
Test #8:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2548
output:
765669726
result:
ok 1 number(s): "765669726"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
12448
output:
159637196
result:
ok 1 number(s): "159637196"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
65535
output:
120089112
result:
ok 1 number(s): "120089112"
Test #11:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
102458
output:
475774506
result:
ok 1 number(s): "475774506"
Test #12:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
222333
output:
64337543
result:
ok 1 number(s): "64337543"
Test #13:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
485174
output:
312492357
result:
ok 1 number(s): "312492357"
Test #14:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
685479
output:
35530508
result:
ok 1 number(s): "35530508"
Test #15:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
1025481
output:
921523794
result:
ok 1 number(s): "921523794"
Test #16:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
9999999
output:
732610409
result:
ok 1 number(s): "732610409"
Test #17:
score: 0
Accepted
time: 1ms
memory: 3800kb
input:
7458658
output:
825346623
result:
ok 1 number(s): "825346623"
Test #18:
score: 0
Accepted
time: 1ms
memory: 3876kb
input:
5268475
output:
30938162
result:
ok 1 number(s): "30938162"
Test #19:
score: 0
Accepted
time: 1ms
memory: 3704kb
input:
2658478
output:
780038100
result:
ok 1 number(s): "780038100"
Test #20:
score: 0
Accepted
time: 1ms
memory: 3740kb
input:
10000000
output:
679483439
result:
ok 1 number(s): "679483439"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
100000000
output:
498142384
result:
ok 1 number(s): "498142384"
Test #22:
score: -100
Wrong Answer
time: 5ms
memory: 3852kb
input:
1000000000
output:
69187984
result:
wrong answer 1st numbers differ - expected: '69187994', found: '69187984'