ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#207642 | #3752. 因数积 | tanghexuan | 100 | 762ms | 4396kb | C++11 | 1.8kb | 2024-07-29 18:55:57 | 2024-07-29 20:06:22 |
answer
#include <bits/stdc++.h>
using namespace std;
static auto __fast_io = []()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
return 0;
}();
// #define DEBUGx
#ifdef DEBUGx
#define TRC_PG(fmt, args...) fprintf(stderr, "\033[1;32m TRC_PG(%s:%d):\t\033[0m" fmt, __func__, __LINE__, ##args)
#define TRC_PR(fmt, args...) fprintf(stderr, "\033[1;31m TRC_PR(%s:%d):\t\033[0m" fmt, __func__, __LINE__, ##args)
#define debug fprintf(stderr, "Passing [%s] in LINE %d\t\n", __func__, __LINE__)
#endif
#ifndef DEBUGx
#define TRC_PG(...)
#define TRC_PR(...)
#define debug
#endif
template <typename _Tp>
_Tp qpow(_Tp a, _Tp b, _Tp m)
{
_Tp t = a % m, ret = 1;
while (b)
{
if (b & 1)
ret = ret * t % m;
b >>= 1, t = t * t % m;
}
return ret;
}
const long long MOD = 998244353;
const int MAX_M = 1e6 + 10;
long long sum[MAX_M], sum2[MAX_M];
long long p[MAX_M];
long long k[MAX_M];
long long ans;
int m;
void input()
{
cin >> m;
for (int i = 1; i <= m; i++)
{
cin >> p[i];
}
for (int i = 1; i <= m; i++)
{
cin >> k[i];
}
sum[0] = 1;
for (int i = 1; i <= m; i++)
{
sum[i] = sum[i - 1] * (k[i] + 1) % (MOD - 1);
}
sum2[m + 1] = 1;
for (int i = m; i >= 1; i--)
{
sum2[i] = sum2[i + 1] * (k[i] + 1) % (MOD - 1);
}
}
void work()
{
ans = 1;
for (int i = 1; i <= m; i++)
{
long long d = ((k[i] + 1) * k[i] / 2) % (MOD - 1) * (sum[i - 1] * sum2[i + 1] % (MOD - 1));
ans = ans * qpow(p[i] % MOD, d % (MOD - 1), MOD) % MOD;
}
}
void output()
{
cout << ans << "\n";
}
int main()
{
// freopen("temp.txt", "r", stdin);
input();
work();
output();
return 0;
}
/*
2
5 11
2 3
821555742
*/
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 5
Accepted
time: 0ms
memory: 1268kb
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: 1268kb
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: 1272kb
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: 1268kb
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: 40ms
memory: 4392kb
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: 44ms
memory: 4392kb
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: 44ms
memory: 4396kb
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: 40ms
memory: 4392kb
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: 32ms
memory: 4396kb
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: 35ms
memory: 4396kb
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: 43ms
memory: 4392kb
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: 36ms
memory: 4392kb
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: 60ms
memory: 4396kb
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: 60ms
memory: 4396kb
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: 57ms
memory: 4392kb
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: 56ms
memory: 4392kb
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: 56ms
memory: 4396kb
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: 45ms
memory: 4392kb
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: 57ms
memory: 4396kb
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: 57ms
memory: 4396kb
input:
100000 9728129 7410971 2501999 2554249 7593617 7909591 1224217 115891 4244503 4454449 2527381 703767...
output:
967919386
result:
ok "967919386"