用户输出
37151122
171244932
236645991
55445263
304269334
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#20640 | #1048. 1-06A. nocriz送温暖 | Accepted | 100 | 277 ms | 3476 K | C++ 11 / 963 B | JM233333 | 2019-07-28 15:39:06 |
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
ll power(ll a, ll n);
ll inv(ll x);
const ll MOD = 998244353;
const int MAX = 2e5 + 5;
ll a[MAX];
ll sum[MAX];
int main() {
// freopen("test.txt", "r", stdin);
int n, q;
while (scanf("%d %d", &n, &q) != EOF) {
// 输入
for (int i = 1; i <= n; i++) {
scanf("%lld", &a[i]);
}
// 求前缀和
sum[0] = 1;
for (int i = 1; i <= n; i++) {
sum[i] = (sum[i - 1] * a[i]) % MOD;
}
// 查询
int l, r;
while (q--) {
// 输入
scanf("%d %d", &l, &r);
// 求解
ll res = (sum[r] * inv(sum[l - 1])) % MOD;
// 输出
printf("%lld\n", res);
}
}
return 0;
}
// 快速幂
ll power(ll a, ll n) {
ll res = 1;
a %= MOD;
while (n > 0) {
if (n % 2 == 1)
res = (res * a) % MOD;
a = (a * a) % MOD;
n /= 2;
}
return res % MOD;
}
// 逆元
inline ll inv(ll x) { return power(x, MOD - 2); }
用户输出
37151122
171244932
236645991
55445263
304269334
系统信息
Exited with return code 0
15 15
165696370 476753897 229689806 996820895 598127751 379659198 554377549 804958724 215644896 7353
<134 bytes omitted>
812259183
486989696
945802145
565758286
410163715
916090137
777479440
197064759
963609266
143548199
<50 bytes omitted>
用户输出
812259183
486989696
945802145
565758286
410163715
916090137
777479440
197064759
963609266
143548199
706406559
574934196
70859561
<22 bytes omitted>
系统信息
Exited with return code 0
500 500
875859693 19297717 533567733 401117518 542067855 942549894 687071639 495756481 706319042 297
<8726 bytes omitted>
416681069
783464821
389635729
915396833
852827187
322964361
795736013
367058069
191319311
945823172
<4858 bytes omitted>
用户输出
416681069
783464821
389635729
915396833
852827187
322964361
795736013
367058069
191319311
945823172
418937528
831914436
19143110
<4830 bytes omitted>
系统信息
Exited with return code 0
1000 1000
453485157 936247494 264621845 889134887 643611901 819233122 269455918 554517854 916438630
<17668 bytes omitted>
481893436
114188653
256055655
866518481
115927372
445439110
945938495
370915673
736335894
299245621
<9789 bytes omitted>
用户输出
481893436
114188653
256055655
866518481
115927372
445439110
945938495
370915673
736335894
299245621
148716341
114948983
83101381
<9761 bytes omitted>
系统信息
Exited with return code 0
5000 5000
946768349 138710211 991772515 390895330 281870111 571810193 822919202 883598607 169120285
<98138 bytes omitted>
864985856
92100437
226580341
499360378
93125908
116831484
933548640
305899388
23514308
451996431
557
<49336 bytes omitted>
用户输出
864985856
92100437
226580341
499360378
93125908
116831484
933548640
305899388
23514308
451996431
5572410
32691982
419975652
9036
<49308 bytes omitted>
系统信息
Exited with return code 0
20000 20000
59910458 346043205 55132948 767676760 594687540 296026148 804076263 216042891 898704108
<423491 bytes omitted>
264861098
450881491
754854261
58003959
48752770
535545407
55061389
468348719
166198501
264776237
254
<197674 bytes omitted>
用户输出
264861098
450881491
754854261
58003959
48752770
535545407
55061389
468348719
166198501
264776237
254081448
579841692
582077438
8
<197646 bytes omitted>
系统信息
Exited with return code 0
50000 50000
10914571 746386359 717378579 224085215 984739017 267333765 956855499 541678257 451519700
<1082564 bytes omitted>
933637921
857402294
582354625
140335565
420947534
73718381
236706476
834562894
485573569
657491365
2
<494348 bytes omitted>
用户输出
933637921
857402294
582354625
140335565
420947534
73718381
236706476
834562894
485573569
657491365
27485262
919880120
13685121
5
<494320 bytes omitted>
系统信息
Exited with return code 0
50000 50000
122286549 265859588 427312049 174066036 78796680 922114383 64120931 991363404 224805463
<1082176 bytes omitted>
997140837
283606682
214721539
548031555
475134263
152394271
294848899
196771768
567435648
334436465
<494194 bytes omitted>
用户输出
997140837
283606682
214721539
548031555
475134263
152394271
294848899
196771768
567435648
334436465
818261380
638590878
58212918
<494166 bytes omitted>
系统信息
Exited with return code 0
100000 100000
157108985 615229511 21768932 970738460 197695722 367294695 642916460 248027698 6977036
<2177053 bytes omitted>
303168480
503863169
553764057
764316760
393488868
947406744
243417456
722363372
219982366
909099658
<988912 bytes omitted>
用户输出
303168480
503863169
553764057
764316760
393488868
947406744
243417456
722363372
219982366
909099658
194723304
47714157
696378561
<988884 bytes omitted>
系统信息
Exited with return code 0
200000 200000
757148 167851001 301413357 336971125 659598369 160567226 391749388 4890852 35766291 2
<4781955 bytes omitted>
933983893
340699169
629640029
502347892
666587249
205473890
609674864
539513027
128544884
2
<2178111 bytes omitted>
用户输出
933983893
340699169
629640029
502347892
666587249
205473890
609674864
539513027
128544884
21777139
636094761
386461303
430217426
<1978083 bytes omitted>
系统信息
Exited with return code 0