用户输出
37151122
171244932
236645991
55445263
304269334
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#21124 | #1048. 1-06A. nocriz送温暖 | Accepted | 100 | 794 ms | 2796 K | C++ 17 / 2.2 K | 自动化82-郭筠陶 | 2020-01-17 11:06:12 |
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const ull mod = 998244353;
/*int main(){
ios::sync_with_stdio(false);
ifstream fin;
fin.open("input");
int n,q; fin>>n>>q;
cout<<n<<q<<endl;
ull curNum = 1;
cout<<2<<"\n";
vector<ull> multiples;
cout<<3<<"\n";
multiples.push_back(1);
cout<<4<<"\n";
for(int i=0;i<n;i++){
ull tmp; fin>>tmp;
curNum=curNum*tmp%mod;
cout<<tmp<<"\t";
cout<<curNum<<"\n";
multiples.push_back(curNum);
}
vector<ull> invs;
invs.push_back(1); invs.push_back(1);
for(int i=2;i<mod;i++){
invs.push_back((mod-mod/i)*invs.at(mod%i)%mod);
//cout<<(mod-mod/i)<<"\t"<<invs.at(mod%i)<<"\t"<<invs.at(i)<<"\n";
}
for(int i=0;i<q;i++){
int l,r; fin>>l>>r;
cout<<((ull)invs.at(multiples.at(l)) * (ull)multiples.at(r)%mod)<<"\n";
}
}*/
inline ull inv(ull a);
ull pow(ull a, ull n);
int main() {
ios::sync_with_stdio(false);
ifstream fin;
fin.open("input");
int n, q;
cin >> n >> q;
vector<ull> multiples;
ull curNum = 1;
vector<int> input(n);
for (int i = 0; i < n; i++) cin >> input.at(i);
multiples.push_back(1);
for (int i = 0; i < n; i++) {
multiples.push_back(multiples.at(i) * input.at(i) % mod);
}
for (int i = 0; i < q; i++) {
int l, r;
cin >> l >> r;
/*cout<<multiples.at(r-1)<<"\t"
<<inv(multiples.at(l-1))<<"\t"
<<multiples.at(r)*inv(multiples.at(l-1))%mod
<<endl;*/
cout << multiples.at(r) * inv(multiples.at(l - 1)) % mod << endl;
}
}
inline ull inv(ull a) { return pow(a, mod - 2); }
ull pow(ull a, ull n) {
ull ans = 1;
for (; n != 0; n /= 2) {
if (n & 1) {
ans *= a;
ans %= mod;
}
a *= a;
a %= mod;
}
return ans;
}
/*int main(){
ios::sync_with_stdio(false);
ifstream fin;
fin.open("input");
int n,q; fin>>n>>q;
vector<ull> multiples;
ull curNum=1;
multiples.push_back(1);
for(int i=0;i<n;i++){
ull tmp; fin>>tmp;
curNum=curNum*tmp%mod;
multiples.push_back(curNum);
}
vector<int> invs(mod+1,1);
for(int i=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