ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207644 | #3752. 因数积 | marcuse | 100 | 778ms | 4284kb | C++ | 1.2kb | 2024-07-29 18:59:54 | 2024-07-29 20:06:36 |
answer
#include <bits/stdc++.h>
#define int unsigned long long
using namespace std;
const int N = 100000 + 10;
const int mod = 998244353;
const int Mod = 998244352;
int n;
int p[N],k[N];
int ans = 1;
int pre[N],bck[N];
int read() {
char ch;
int sum = 0,flag = 1;
ch = getchar();
while(ch < '0' || ch > '9') {
if(ch == '-') flag = -flag;
ch = getchar();
}
while(ch >= '0' && ch <= '9') {
sum = sum * 10 + ch - '0';
ch = getchar();
}
return sum * flag;
}
int Pow(int x,int b){
int res = 1;
for(; b; b = b >> 1){if(b & 1) res = (res % mod * x % mod) % mod; x = (x * x) % mod;}
return res % mod;
}
signed main(){
n = read();
for(int i = 1; i <= n; i++){
p[i] = read();
}
for(int i = 1; i <= n; i++){
k[i] = read();
}
pre[0] = bck[n + 1] = 1;
for(int i = 1; i <= n; i++){
pre[i] = (pre[i - 1] % Mod * (k[i] + 1) % Mod) % Mod;
}
for(int i = n; i >= 1; i--){
bck[i] = (bck[i + 1] % Mod * (k[i] + 1) % Mod) % Mod;
}
for(int i = 1; i <= n; i++){
int c = (k[i] + 1) * k[i] / 2;
int res = Pow(p[i],c) % mod;
int ci = (bck[i + 1] % (mod - 1) * pre[i - 1] % (mod - 1)) % (mod - 1);
ans = (ans % mod * Pow(res,ci) % mod) % mod;
}
cout << ans % mod << endl;
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1176kb
input:
9 6483823 7841627 6531457 1745437 5716133 6476347 2562589 2048159 5063327 1 1 1 3 3 4 2 3 2
output:
366170442
result:
ok "366170442"
Test #2:
score: 5
Accepted
time: 0ms
memory: 1172kb
input:
10 1877741 2586343 8391841 5733523 5462239 4869727 2672687 224131 6917221 3023513 1 1 1 3 5 1 2 2 2 2
output:
422478355
result:
ok "422478355"
Test #3:
score: 5
Accepted
time: 0ms
memory: 1176kb
input:
8 5672731 8359979 2024933 6169399 5069413 4825871 4393387 6306077 4 1 1 5 2 3 2 2
output:
7109854
result:
ok "7109854"
Test #4:
score: 5
Accepted
time: 0ms
memory: 1176kb
input:
9 6526313 3707629 9454421 98453 8100557 3776081 1702747 4999703 9301819 1 2 3 4 3 2 2 1 2
output:
675660435
result:
ok "675660435"
Test #5:
score: 5
Accepted
time: 29ms
memory: 4280kb
input:
100000 9551959 9703151 2189867 8400253 2041583 18353 6827923 4157893 1305401 1243157 1694551 1915481...
output:
395868439
result:
ok "395868439"
Test #6:
score: 5
Accepted
time: 24ms
memory: 4280kb
input:
100000 1777411 1273681 8286133 2521969 2319613 9679807 3304673 1297091 3885803 3247609 2566199 95322...
output:
598530404
result:
ok "598530404"
Test #7:
score: 5
Accepted
time: 28ms
memory: 4280kb
input:
100000 1238197 9552689 1604263 3704621 2748313 4901359 108727 4505029 3688193 4928533 9726221 362638...
output:
687191030
result:
ok "687191030"
Test #8:
score: 5
Accepted
time: 25ms
memory: 4280kb
input:
100000 5437979 182341 8064713 6661301 2602177 3929557 6259039 1488301 1378999 139361 3309469 5616557...
output:
649523073
result:
ok "649523073"
Test #9:
score: 5
Accepted
time: 28ms
memory: 4280kb
input:
100000 9379003 7849483 7194563 2999597 6585479 5785807 400903 1998701 5246399 7677589 488993 3216677...
output:
1
result:
ok "1"
Test #10:
score: 5
Accepted
time: 26ms
memory: 4280kb
input:
100000 3915157 7267069 269749 2939081 8301619 6081353 5571179 7051453 3775637 6347203 6488941 320294...
output:
940784847
result:
ok "940784847"
Test #11:
score: 5
Accepted
time: 26ms
memory: 4284kb
input:
100000 7975169 7282831 9977041 6161873 9975851 6375571 2755387 5926477 8737801 1934531 3385153 25805...
output:
503749204
result:
ok "503749204"
Test #12:
score: 5
Accepted
time: 23ms
memory: 4284kb
input:
100000 857653 6280333 11287 7485997 3780599 4999427 1839329 1438939 4407493 6502267 8494901 3309221 ...
output:
296273185
result:
ok "296273185"
Test #13:
score: 5
Accepted
time: 73ms
memory: 4280kb
input:
100000 2372507 1934113 2655053 8245711 7210999 6561637 5239391 5428469 854417 5469899 9808501 143272...
output:
893962281
result:
ok "893962281"
Test #14:
score: 5
Accepted
time: 69ms
memory: 4284kb
input:
100000 9544877 1700087 9389561 3627367 4045121 1827829 7836079 9357919 3194119 4891591 6471691 41872...
output:
741940036
result:
ok "741940036"
Test #15:
score: 5
Accepted
time: 74ms
memory: 4284kb
input:
100000 178447 5712919 6434371 1401287 7999319 966377 6907349 8838979 7719893 272737 5631221 1682671 ...
output:
878697914
result:
ok "878697914"
Test #16:
score: 5
Accepted
time: 72ms
memory: 4280kb
input:
100000 7232377 7969747 1322767 2291591 2910779 4381051 7874939 8597143 8124427 6411593 2008679 39737...
output:
530316372
result:
ok "530316372"
Test #17:
score: 5
Accepted
time: 72ms
memory: 4280kb
input:
100000 7295647 867563 345887 5121173 3200557 6001997 7972831 4003231 1567327 9891061 1513537 4118749...
output:
764801899
result:
ok "764801899"
Test #18:
score: 5
Accepted
time: 72ms
memory: 4280kb
input:
100000 265511 8930599 8924477 1516199 7493881 4028231 421847 4113943 487873 2386121 3261133 3032321 ...
output:
554924681
result:
ok "554924681"
Test #19:
score: 5
Accepted
time: 69ms
memory: 4280kb
input:
100000 1093837 8751151 9278363 7985093 5225371 6490907 9783247 4021207 2781203 1454983 8725733 29996...
output:
255683247
result:
ok "255683247"
Test #20:
score: 5
Accepted
time: 68ms
memory: 4280kb
input:
100000 9728129 7410971 2501999 2554249 7593617 7909591 1224217 115891 4244503 4454449 2527381 703767...
output:
967919386
result:
ok "967919386"