QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574304#9309. Graphucup-team2172RE 126ms99580kbC++141.4kb2024-09-18 21:28:272024-09-18 21:28:28

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 21:28:28]
  • 评测
  • 测评结果:RE
  • 用时:126ms
  • 内存:99580kb
  • [2024-09-18 21:28:27]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n;
const int N = 1e7;
const int mod = 998244353;
ll g[N << 1];
int id(ll i){
    return i < N ? i : N + n / i;
}
int qp(int x, int k){
    int res = 1;
    while(k){
        if(k & 1) res = 1LL * res * x % mod;
        k >>= 1, x = 1LL * x * x % mod;
    }
    return res;
}
int tot;
int prime[N];
bool check[N];
void init(){
    for(int i = 2; i < N; i++){
        if(!check[i]) prime[++tot] = i;
        for(int j = 1; j <= tot; j++){
            if(i * prime[j] >= N) break;
            check[i * prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
}
int cal(ll x){
    if(x <= 3) return x <= 2 ? 1 : 3; 
    ll cntp = g[id(x)] - g[id(x / 2)];
    return 1LL * (x - cntp - 1) % mod * qp(x % mod, cntp) % mod;
}
int main(){
    init();
    cin >> n;
    init();
    int ans = 1;
    for(ll i = n; i > 1; i = n / (n / i + 1)){
        g[id(i)] = i - 1;
    }
    for(int j = 1; 1LL * prime[j] * prime[j] <= n; j++){
        for(int i = n; i >= prime[j] * prime[j]; i = n / (n / i + 1)){
            g[id(i)] -= g[id(i / prime[j])] - g[id(prime[j - 1])];
        }
    }
    for(ll l = 1, r; l <= n; l = r + 1){
        r = n / (n / l);
        int res = cal(n / l);
        ans = 1LL * ans * qp(res, r - l + 1) % mod; 
    }
    cout<<ans;
}

詳細信息

Test #1:

score: 100
Accepted
time: 68ms
memory: 18976kb

input:

4

output:

8

result:

ok answer is '8'

Test #2:

score: 0
Accepted
time: 69ms
memory: 20156kb

input:

2

output:

1

result:

ok answer is '1'

Test #3:

score: 0
Accepted
time: 71ms
memory: 19428kb

input:

123

output:

671840470

result:

ok answer is '671840470'

Test #4:

score: 0
Accepted
time: 59ms
memory: 19232kb

input:

233

output:

353738465

result:

ok answer is '353738465'

Test #5:

score: 0
Accepted
time: 67ms
memory: 19072kb

input:

5981

output:

970246821

result:

ok answer is '970246821'

Test #6:

score: 0
Accepted
time: 71ms
memory: 20764kb

input:

86422

output:

897815688

result:

ok answer is '897815688'

Test #7:

score: 0
Accepted
time: 69ms
memory: 22764kb

input:

145444

output:

189843901

result:

ok answer is '189843901'

Test #8:

score: 0
Accepted
time: 67ms
memory: 23672kb

input:

901000

output:

819449452

result:

ok answer is '819449452'

Test #9:

score: 0
Accepted
time: 68ms
memory: 26364kb

input:

1000000

output:

113573943

result:

ok answer is '113573943'

Test #10:

score: 0
Accepted
time: 71ms
memory: 56304kb

input:

23333333

output:

949849384

result:

ok answer is '949849384'

Test #11:

score: 0
Accepted
time: 71ms
memory: 82208kb

input:

102850434

output:

604886751

result:

ok answer is '604886751'

Test #12:

score: 0
Accepted
time: 99ms
memory: 99580kb

input:

998244353

output:

0

result:

ok answer is '0'

Test #13:

score: 0
Accepted
time: 102ms
memory: 98156kb

input:

1000000007

output:

318420284

result:

ok answer is '318420284'

Test #14:

score: 0
Accepted
time: 126ms
memory: 99176kb

input:

2147483547

output:

688759898

result:

ok answer is '688759898'

Test #15:

score: -100
Runtime Error

input:

5120103302

output:


result: