Solutions are presented as using the least memory and the fastest execution time. It also takes the top
10 most recent solutions from each language. If you want to limit to a specific index, click the
"Solved" button and go to that problem.
Problems
B'Priests of the Quetzalcoatl cult want to build a tower to represent a power of their god. Tower is usually made of power-charged rocks. It is built with the help of rare magic by levitating the current top of tower and adding rocks at its bottom. If top, which is built from k xe2 x80 x89- xe2 x80 x891 rocks, possesses power p and we want to add the rock charged with power wk then value of power of a new tower will be {wk}p. Rocks are added from the last to the first. That is for sequence w1, xe2 x80 x89..., xe2 x80 x89wm value of power will be After tower is built, its power may be extremely large. But still priests want to get some information about it, namely they want to know a number called cumulative power which is the true value of power taken modulo m. Priests have n rocks numbered from 1 to n. They ask you to calculate which value of cumulative power will the tower possess if they will build it from rocks numbered l, xe2 x80 x89l xe2 x80 x89+ xe2 x80 x891, xe2 x80 x89..., xe2 x80 x89r. First line of input contains two integers n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105) and m (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89m xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109). Second line of input contains n integers wk (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89wk xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109) which is the power of rocks that priests have. Third line of input contains single integer q (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89q xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89105) which is amount of queries from priests to you. kth of next q lines contains two integers lk and rk (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89lk xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89rk xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n). Output q integers. k-th of them must be the amount of cumulative power the tower will have if is built from rocks lk, xe2 x80 x89lk xe2 x80 x89+ xe2 x80 x891, xe2 x80 x89..., xe2 x80 x89rk. 327 xe2 x80 x89= xe2 x80 x897625597484987 '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
33586438 |
lzr_010506 |
D |
Dec. 24, 2017, 7:23 a.m. |
OK |
GNU C++ |
TESTS |
130 |
576 |
2457600 |
|
2600 |
38386739 |
SpiritualKhorosho |
D |
May 18, 2018, 2:31 a.m. |
OK |
GNU C++ |
TESTS |
130 |
592 |
512000 |
|
2600 |
33554166 |
SkyDec |
D |
Dec. 23, 2017, 2:49 p.m. |
OK |
GNU C++ |
TESTS |
130 |
592 |
2969600 |
|
2600 |
33608145 |
vjudge1 |
D |
Dec. 25, 2017, 4:17 a.m. |
OK |
GNU C++ |
TESTS |
130 |
592 |
3481600 |
|
2600 |
33608140 |
Landia |
D |
Dec. 25, 2017, 4:16 a.m. |
OK |
GNU C++ |
TESTS |
130 |
592 |
3481600 |
|
2600 |
33607912 |
vjudge3 |
D |
Dec. 25, 2017, 3:49 a.m. |
OK |
GNU C++ |
TESTS |
130 |
592 |
3481600 |
|
2600 |
33607906 |
Landia |
D |
Dec. 25, 2017, 3:49 a.m. |
OK |
GNU C++ |
TESTS |
130 |
592 |
3481600 |
|
2600 |
34799561 |
Scut82 |
D |
Feb. 1, 2018, 11:04 a.m. |
OK |
GNU C++ |
TESTS |
130 |
608 |
2457600 |
|
2600 |
34406354 |
Scut82 |
D |
Jan. 21, 2018, 8:41 a.m. |
OK |
GNU C++ |
TESTS |
130 |
608 |
3276800 |
|
2600 |
38386803 |
E.Space |
D |
May 18, 2018, 2:34 a.m. |
OK |
GNU C++ |
TESTS |
130 |
639 |
716800 |
|
2600 |
46371294 |
cortan122 |
D |
Nov. 29, 2018, 3:58 p.m. |
OK |
GNU C11 |
TESTS |
130 |
1153 |
819200 |
|
2600 |
53872436 |
luogu_bot1 |
D |
May 8, 2019, 10:02 a.m. |
OK |
GNU C++11 |
TESTS |
130 |
546 |
16281600 |
|
2600 |
50771324 |
Louhc |
D |
March 4, 2019, 5:04 a.m. |
OK |
GNU C++11 |
TESTS |
130 |
561 |
409600 |
|
2600 |
60281455 |
luogu_bot2 |
D |
Sept. 8, 2019, 9:12 p.m. |
OK |
GNU C++11 |
TESTS |
130 |
561 |
409600 |
|
2600 |
50409960 |
luogu_bot1 |
D |
Feb. 24, 2019, 1:24 a.m. |
OK |
GNU C++11 |
TESTS |
130 |
561 |
819200 |
|
2600 |
64497180 |
gsyz |
D |
Nov. 8, 2019, 1:02 a.m. |
OK |
GNU C++11 |
TESTS |
130 |
561 |
4403200 |
|
2600 |
50604483 |
Gloid |
D |
Feb. 28, 2019, 2 p.m. |
OK |
GNU C++11 |
TESTS |
130 |
576 |
1228800 |
|
2600 |
49550610 |
PresHerobrine |
D |
Feb. 7, 2019, 5:33 a.m. |
OK |
GNU C++11 |
TESTS |
130 |
576 |
1638400 |
|
2600 |
56515921 |
luogu_bot3 |
D |
July 4, 2019, 12:42 p.m. |
OK |
GNU C++11 |
TESTS |
130 |
576 |
4300800 |
|
2600 |
58209990 |
spsicio |
D |
Aug. 3, 2019, 8:29 a.m. |
OK |
GNU C++11 |
TESTS |
130 |
577 |
409600 |
|
2600 |
64460274 |
justin_cao |
D |
Nov. 7, 2019, 10:06 a.m. |
OK |
GNU C++11 |
TESTS |
130 |
577 |
819200 |
|
2600 |
36306150 |
aid |
D |
March 15, 2018, 3:38 p.m. |
OK |
GNU C++14 |
TESTS |
130 |
326 |
6451200 |
|
2600 |
40978814 |
ReaLNero1 |
D |
July 30, 2018, 4:49 p.m. |
OK |
GNU C++14 |
TESTS |
130 |
342 |
4608000 |
|
2600 |
33565188 |
dotorya |
D |
Dec. 23, 2017, 3:40 p.m. |
OK |
GNU C++14 |
TESTS |
130 |
467 |
2560000 |
|
2600 |
33658191 |
letsbe |
D |
Dec. 26, 2017, 10:30 p.m. |
OK |
GNU C++14 |
TESTS |
130 |
467 |
3788800 |
|
2600 |
33570158 |
khadaev |
D |
Dec. 23, 2017, 4:02 p.m. |
OK |
GNU C++14 |
TESTS |
130 |
576 |
2457600 |
|
2600 |
69596683 |
guestIT |
D |
Jan. 27, 2020, 5:14 a.m. |
OK |
GNU C++14 |
TESTS |
130 |
577 |
819200 |
|
2600 |
65620236 |
marcOS |
D |
Nov. 24, 2019, 5:56 a.m. |
OK |
GNU C++14 |
TESTS |
130 |
577 |
16384000 |
|
2600 |
69598717 |
guestIT |
D |
Jan. 27, 2020, 6:25 a.m. |
OK |
GNU C++14 |
TESTS |
130 |
592 |
409600 |
|
2600 |
46666723 |
nganhvu |
D |
Dec. 6, 2018, 3:02 a.m. |
OK |
GNU C++14 |
TESTS |
130 |
592 |
512000 |
|
2600 |
69596767 |
guestIT |
D |
Jan. 27, 2020, 5:18 a.m. |
OK |
GNU C++14 |
TESTS |
130 |
592 |
512000 |
|
2600 |
67175950 |
how_to_become_purple |
D |
Dec. 18, 2019, 7:15 p.m. |
OK |
GNU C++17 |
TESTS |
130 |
452 |
1024000 |
|
2600 |
61200260 |
Lich_King |
D |
Sept. 24, 2019, 7:28 a.m. |
OK |
GNU C++17 |
TESTS |
130 |
624 |
409600 |
|
2600 |
62849313 |
Henry_Huang |
D |
Oct. 18, 2019, 6:41 a.m. |
OK |
GNU C++17 |
TESTS |
130 |
639 |
1638400 |
|
2600 |
47719200 |
Shayan.P |
D |
Dec. 30, 2018, 10:03 a.m. |
OK |
GNU C++17 |
TESTS |
130 |
654 |
3379200 |
|
2600 |
49949041 |
vjudge4 |
D |
Feb. 15, 2019, 1:18 p.m. |
OK |
GNU C++17 |
TESTS |
130 |
655 |
409600 |
|
2600 |
56405089 |
Sang_Hoon |
D |
July 1, 2019, 6:55 p.m. |
OK |
GNU C++17 |
TESTS |
130 |
670 |
409600 |
|
2600 |
47666328 |
374272 |
D |
Dec. 29, 2018, 12:46 a.m. |
OK |
GNU C++17 |
TESTS |
130 |
670 |
614400 |
|
2600 |
59484677 |
t_swizzle141 |
D |
Aug. 25, 2019, 4:42 p.m. |
OK |
GNU C++17 |
TESTS |
130 |
670 |
8192000 |
|
2600 |
49948992 |
JHzzzzZ |
D |
Feb. 15, 2019, 1:17 p.m. |
OK |
GNU C++17 |
TESTS |
130 |
685 |
409600 |
|
2600 |
64182313 |
vjudge2 |
D |
Nov. 4, 2019, 2:03 a.m. |
OK |
GNU C++17 |
TESTS |
130 |
685 |
512000 |
|
2600 |
33704425 |
JialinOuyang |
D |
Dec. 28, 2017, 8:30 a.m. |
OK |
Java 8 |
TESTS |
130 |
1013 |
20787200 |
|
2600 |
55825930 |
ajkdrag |
D |
June 20, 2019, 10:51 a.m. |
OK |
Java 8 |
TESTS |
130 |
1014 |
0 |
|
2600 |
55825382 |
ajkdrag |
D |
June 20, 2019, 10:36 a.m. |
OK |
Java 8 |
TESTS |
130 |
1044 |
0 |
|
2600 |
33559340 |
uwi |
D |
Dec. 23, 2017, 3:11 p.m. |
OK |
Java 8 |
TESTS |
130 |
1060 |
61235200 |
|
2600 |
34189659 |
tri |
D |
Jan. 15, 2018, 6:07 a.m. |
OK |
Java 8 |
TESTS |
130 |
1232 |
20787200 |
|
2600 |
43689949 |
rohanakar |
D |
Oct. 2, 2018, 1:55 p.m. |
OK |
Java 8 |
TESTS |
130 |
1559 |
0 |
|
2600 |
33653594 |
Kharouba |
D |
Dec. 26, 2017, 4:52 p.m. |
OK |
Java 8 |
TESTS |
130 |
1777 |
20889600 |
|
2600 |
33653822 |
Kharouba |
D |
Dec. 26, 2017, 5:02 p.m. |
OK |
Java 8 |
TESTS |
130 |
1793 |
20889600 |
|
2600 |
33585188 |
hiromi_ayase |
D |
Dec. 24, 2017, 6:25 a.m. |
OK |
Java 8 |
TESTS |
130 |
1809 |
21094400 |
|
2600 |
33650662 |
Aidos |
D |
Dec. 26, 2017, 3:25 p.m. |
OK |
Java 8 |
TESTS |
130 |
1964 |
20787200 |
|
2600 |
41892596 |
vjudge3 |
D |
Aug. 20, 2018, 7:52 a.m. |
OK |
MS C++ |
TESTS |
130 |
889 |
819200 |
|
2600 |
65572585 |
vjudge3 |
D |
Nov. 23, 2019, 8:21 a.m. |
OK |
MS C++ |
TESTS |
130 |
919 |
1638400 |
|
2600 |
65591242 |
vjudge4 |
D |
Nov. 23, 2019, 2:12 p.m. |
OK |
MS C++ |
TESTS |
130 |
920 |
409600 |
|
2600 |
65574524 |
vjudge2 |
D |
Nov. 23, 2019, 8:56 a.m. |
OK |
MS C++ |
TESTS |
130 |
951 |
819200 |
|
2600 |
60217777 |
vjudge3 |
D |
Sept. 7, 2019, 12:27 p.m. |
OK |
MS C++ |
TESTS |
130 |
1013 |
819200 |
|
2600 |
65618391 |
vjudge3 |
D |
Nov. 24, 2019, 5:10 a.m. |
OK |
MS C++ |
TESTS |
130 |
1029 |
819200 |
|
2600 |
65561949 |
vjudge4 |
D |
Nov. 23, 2019, 3:30 a.m. |
OK |
MS C++ |
TESTS |
130 |
1185 |
1638400 |
|
2600 |
65591885 |
vjudge2 |
D |
Nov. 23, 2019, 2:24 p.m. |
OK |
MS C++ |
TESTS |
130 |
1980 |
7987200 |
|
2600 |
57436220 |
jqmin |
D |
July 21, 2019, 4:54 a.m. |
OK |
MS C++ 2017 |
TESTS |
130 |
857 |
409600 |
|
2600 |
65577245 |
vjudge2 |
D |
Nov. 23, 2019, 9:48 a.m. |
OK |
MS C++ 2017 |
TESTS |
130 |
951 |
819200 |
|
2600 |
65577002 |
vjudge1 |
D |
Nov. 23, 2019, 9:43 a.m. |
OK |
MS C++ 2017 |
TESTS |
130 |
966 |
819200 |
|
2600 |
65576965 |
vjudge5 |
D |
Nov. 23, 2019, 9:42 a.m. |
OK |
MS C++ 2017 |
TESTS |
130 |
1076 |
819200 |
|
2600 |
65575505 |
vjudge1 |
D |
Nov. 23, 2019, 9:15 a.m. |
OK |
MS C++ 2017 |
TESTS |
130 |
1107 |
819200 |
|
2600 |
65577202 |
vjudge4 |
D |
Nov. 23, 2019, 9:47 a.m. |
OK |
MS C++ 2017 |
TESTS |
130 |
1169 |
819200 |
|
2600 |
remove filters
Back to search problems