QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#164090 | #7046. Function! | wifi32767# | WA | 1ms | 3752kb | C++20 | 1.3kb | 2023-09-04 19:39:30 | 2023-09-04 19:39:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lll __int128
const int MAX = 1e3 + 10, mod = 998244353;
ll n, k;
lll ans = 0;
ll safe_sqrt(ll x){
ll lk = 0, rk = 2 * sqrt(x);
while (lk < rk){
ll mid = (lk + rk) >> 1;
if (mid * mid >= x) rk = mid;
else lk = mid + 1;
}
return lk;
}
void write(lll x){
if(x < 0)
putchar('-'),x = -x;
if(x > 9)
write(x / 10);
putchar(x % 10 + '0');
return;
}
lll cal(ll y){
lll x = y;
return (2 * x * x * x + 3 * x * x + x) / 6 % mod;
}
void solve(){
cin >> n;
k = safe_sqrt(n);
for (int i = 2; i <= k; ++ i){
ll t = i - 1;
int cnt = 1;
while (t < n){
ll m = (t + 1) * i - 1;
if (m > n) ans = (ans + i * cnt * (n - t) % mod) % mod;
else ans = (ans + i * cnt * (m - t) % mod) % mod;
t = m;
cnt ++;
}
}
ans = (ans + (n + 1) * (n + k + 1) % mod * (n - k) / 2) % mod;
ans += mod + cal(k) - cal(n);
write(ans % mod);
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//cout << fixed << setprecision(20);
//while (cin >> n)
//write(cal(1e12));
//int _;cin>>_;while(_--)
solve();
//did();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3552kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
10
output:
236
result:
ok 1 number(s): "236"
Test #3:
score: 0
Accepted
time: 1ms
memory: 3752kb
input:
20
output:
1646
result:
ok 1 number(s): "1646"
Test #4:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
27
output:
3862
result:
ok 1 number(s): "3862"
Test #5:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
37
output:
9571
result:
ok 1 number(s): "9571"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
100
output:
175028
result:
ok 1 number(s): "175028"
Test #7:
score: 0
Accepted
time: 1ms
memory: 3544kb
input:
123
output:
322744
result:
ok 1 number(s): "322744"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3552kb
input:
2548
output:
765669726
result:
ok 1 number(s): "765669726"
Test #9:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
12448
output:
159637196
result:
ok 1 number(s): "159637196"
Test #10:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
65535
output:
120089112
result:
ok 1 number(s): "120089112"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3576kb
input:
102458
output:
475774506
result:
ok 1 number(s): "475774506"
Test #12:
score: -100
Wrong Answer
time: 1ms
memory: 3580kb
input:
222333
output:
563459719
result:
wrong answer 1st numbers differ - expected: '64337543', found: '563459719'