QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#521845 | #7046. Function! | QF_love_younger_sister | WA | 0ms | 3732kb | C++23 | 921b | 2024-08-16 15:47:14 | 2024-08-16 15:47:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod=998244353;
int qpow(int a, int b, int p)
{
int res = 1;
while(b)
{
if(b & 1) res = res * a % p;
a = a * a % p;
b >>= 1;
}
return res;
}
int qpow1(int a,int b){
int res = 1;
while(b)
{
if(b & 1) res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
int ny(int x){
return qpow(x,mod-2,mod);
}
int qf(int n){
return n%mod*(n+1)%mod*(2*n%mod+1)%mod*ny(6)%mod;
}
signed main(){
int n,sum=0;
cin >> n;
for(int a=2;a<=sqrt(n);a++){
int k=2;
while(qpow1(a,k)<=n){
k++;
}
k--;
sum=(sum+a%mod*(n+1)%mod*k%mod-a%mod*a%mod*((qpow(a,k,mod)+mod-1)%mod)*ny(a-1)%mod)%mod;
}
int a1=sqrt(n);
a1++;
// cout << a1 << "\n";
// cout << qf(n) << " " << qf(a1-1) << "\n";
sum=(sum+(a1+n)%mod*(n-a1+1)%mod*(n+1)%mod*ny(2)%mod-qf(n)+qf(a1-1))%mod;
cout << sum;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3720kb
input:
2
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
10
output:
236
result:
ok 1 number(s): "236"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
20
output:
1646
result:
ok 1 number(s): "1646"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
27
output:
3862
result:
ok 1 number(s): "3862"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
37
output:
9571
result:
ok 1 number(s): "9571"
Test #6:
score: 0
Accepted
time: 0ms
memory: 3732kb
input:
100
output:
175028
result:
ok 1 number(s): "175028"
Test #7:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
123
output:
322744
result:
ok 1 number(s): "322744"
Test #8:
score: -100
Wrong Answer
time: 0ms
memory: 3668kb
input:
2548
output:
-232574627
result:
wrong answer 1st numbers differ - expected: '765669726', found: '-232574627'