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"Some time ago Leonid have known about idempotent functions. Idempotent function defined on a set {1, xe2 x80 x892, xe2 x80 x89..., xe2 x80 x89n} is such function , that for any the formula g(g(x)) xe2 x80 x89= xe2 x80 x89g(x) holds. Let's denote as f(k)(x) the function f applied k times to the value x. More formally, f(1)(x) xe2 x80 x89= xe2 x80 x89f(x), f(k)(x) xe2 x80 x89= xe2 x80 x89f(f(k xe2 x80 x89- xe2 x80 x891)(x)) for each k xe2 x80 x89> xe2 x80 x891. You are given some function . Your task is to find minimum positive integer k such that function f(k)(x) is idempotent. In the first line of the input there is a single integer n (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89200) -- the size of function f domain. In the second line follow f(1), xe2 x80 x89f(2), xe2 x80 x89..., xe2 x80 x89f(n) (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89f(i) xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n for each 1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89i xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n), the values of a function. Output minimum k such that function f(k)(x) is idempotent. In the first sample test function f(x) xe2 x80 x89= xe2 x80 x89f(1)(x) is already idempotent since f(f(1)) xe2 x80 x89= xe2 x80 x89f(1) xe2 x80 x89= xe2 x80 x891, f(f(2)) xe2 x80 x89= xe2 x80 x89f(2) xe2 x80 x89= xe2 x80 x892, f(f(3)) xe2 x80 x89= xe2 x80 x89f(3) xe2 x80 x89= xe2 x80 x892, f(f(4)) xe2 x80 x89= xe2 x80 x89f(4) xe2 x80 x89= xe2 x80 x894. In the second sample test: In the third sample test: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
10990254 |
ruban |
C |
May 3, 2015, 7:11 p.m. |
OK |
Delphi |
TESTS |
65 |
31 |
14643200 |
|
2000 |
10990241 |
ruban1 |
C |
May 3, 2015, 7:10 p.m. |
OK |
Delphi |
TESTS |
65 |
31 |
14643200 |
|
2000 |
10997138 |
vuonghy2442 |
C |
May 4, 2015, 3:18 p.m. |
OK |
FPC |
TESTS |
65 |
15 |
0 |
|
2000 |
11141485 |
ez_cjb |
C |
May 19, 2015, 7:47 a.m. |
OK |
FPC |
TESTS |
65 |
30 |
0 |
|
2000 |
11276008 |
vjudge1 |
C |
May 26, 2015, 9:04 a.m. |
OK |
FPC |
TESTS |
65 |
30 |
102400 |
|
2000 |
10993361 |
igdor99 |
C |
May 4, 2015, 7:33 a.m. |
OK |
FPC |
TESTS |
65 |
30 |
3686400 |
|
2000 |
11276158 |
vjudge1 |
C |
May 26, 2015, 9:17 a.m. |
OK |
FPC |
TESTS |
65 |
31 |
0 |
|
2000 |
11276132 |
vjudge3 |
C |
May 26, 2015, 9:14 a.m. |
OK |
FPC |
TESTS |
65 |
31 |
0 |
|
2000 |
10994428 |
AbstractKangaroo |
C |
May 4, 2015, 10:27 a.m. |
OK |
FPC |
TESTS |
65 |
31 |
0 |
|
2000 |
10994087 |
vanyak999 |
C |
May 4, 2015, 9:29 a.m. |
OK |
FPC |
TESTS |
65 |
31 |
0 |
|
2000 |
11278272 |
louisja1 |
C |
May 26, 2015, 12:15 p.m. |
OK |
FPC |
TESTS |
65 |
31 |
0 |
|
2000 |
11013638 |
chicken_coder |
C |
May 6, 2015, 2:06 p.m. |
OK |
FPC |
TESTS |
65 |
31 |
102400 |
|
2000 |
30013983 |
jiyutian |
C |
Sept. 2, 2017, 1:42 p.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
20673767 |
zhan8855 |
C |
Sept. 17, 2016, 5:39 a.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
19507943 |
bahuangliuhe |
C |
July 30, 2016, 3:26 a.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
17035121 |
DEGwer |
C |
March 30, 2016, 1:53 p.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
16650011 |
alex20030190 |
C |
March 11, 2016, 2 p.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
16054918 |
cacyth |
C |
Feb. 16, 2016, 11:36 a.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
15188804 |
vjudge4 |
C |
Jan. 5, 2016, 8:08 a.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
14909848 |
Hachiikung |
C |
Dec. 21, 2015, 9:34 a.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
14909813 |
Hachiikung |
C |
Dec. 21, 2015, 9:31 a.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
14664083 |
vjudge1 |
C |
Dec. 5, 2015, 2:41 p.m. |
OK |
GNU C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
31105342 |
vjudge5 |
C |
Oct. 7, 2017, 8:13 a.m. |
OK |
GNU C11 |
TESTS |
65 |
15 |
0 |
|
2000 |
19462952 |
satashun |
C |
July 28, 2016, 2:10 p.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
31106521 |
theodor.moroianu |
C |
Oct. 7, 2017, 8:42 a.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
27107900 |
Mahdi_Jfri |
C |
May 14, 2017, 2:04 p.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
20652526 |
tommyricardo |
C |
Sept. 16, 2016, 4:44 a.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
20385283 |
Hackrxer |
C |
Sept. 4, 2016, 3:34 p.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
18759062 |
saliii |
C |
June 27, 2016, 10:38 p.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
16594718 |
spare |
C |
March 8, 2016, 2:43 a.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
16551254 |
v.haralampiev |
C |
March 6, 2016, 11:30 a.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
15739300 |
Deemo |
C |
Feb. 1, 2016, 8:16 p.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
15724531 |
hogloid |
C |
Feb. 1, 2016, 4:53 a.m. |
OK |
GNU C++11 |
TESTS |
65 |
15 |
0 |
|
2000 |
30949216 |
monster |
C |
Oct. 2, 2017, 5:11 p.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
30835535 |
vjudge1 |
C |
Sept. 29, 2017, 4:33 p.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
30819452 |
cxt |
C |
Sept. 29, 2017, 3:17 a.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
29673800 |
Fischer |
C |
Aug. 22, 2017, 4:47 a.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
29672597 |
Fischer |
C |
Aug. 22, 2017, 3:11 a.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
29672575 |
Fischer |
C |
Aug. 22, 2017, 3:10 a.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
29672559 |
Fischer |
C |
Aug. 22, 2017, 3:08 a.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
27477958 |
cr0n |
C |
June 1, 2017, 5:34 a.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
27057223 |
dhsrhkdgus |
C |
May 12, 2017, 3:12 p.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
31780041 |
vjudge2 |
C |
Oct. 27, 2017, 4:57 a.m. |
OK |
GNU C++14 |
TESTS |
65 |
15 |
0 |
|
2000 |
59596480 |
briansu |
C |
Aug. 28, 2019, 2:12 a.m. |
OK |
GNU C++17 |
TESTS |
65 |
30 |
0 |
|
2000 |
50704594 |
CaroLinda |
C |
March 3, 2019, 2:33 a.m. |
OK |
GNU C++17 |
TESTS |
65 |
30 |
0 |
|
2000 |
43952100 |
crathva |
C |
Oct. 7, 2018, 5:03 p.m. |
OK |
GNU C++17 |
TESTS |
65 |
30 |
0 |
|
2000 |
59862412 |
boook |
C |
Sept. 1, 2019, 3:49 p.m. |
OK |
GNU C++17 |
TESTS |
65 |
30 |
0 |
|
2000 |
59881356 |
edisonhello |
C |
Sept. 2, 2019, 5:10 a.m. |
OK |
GNU C++17 |
TESTS |
65 |
30 |
204800 |
|
2000 |
37836089 |
Hash_Mallow |
C |
May 2, 2018, 10:06 a.m. |
OK |
GNU C++17 |
TESTS |
65 |
30 |
3481600 |
|
2000 |
68488633 |
Phortox |
C |
Jan. 10, 2020, 10:50 a.m. |
OK |
GNU C++17 |
TESTS |
65 |
31 |
0 |
|
2000 |
64678980 |
RUSH_D_CAT |
C |
Nov. 11, 2019, 9:13 a.m. |
OK |
GNU C++17 |
TESTS |
65 |
31 |
0 |
|
2000 |
64624464 |
ruo |
C |
Nov. 10, 2019, 8:05 a.m. |
OK |
GNU C++17 |
TESTS |
65 |
31 |
0 |
|
2000 |
61525879 |
ivan100sic |
C |
Sept. 29, 2019, 10:18 p.m. |
OK |
GNU C++17 |
TESTS |
65 |
31 |
0 |
|
2000 |
10991712 |
emo |
C |
May 4, 2015, 12:08 a.m. |
OK |
Java 7 |
TESTS |
65 |
77 |
0 |
|
2000 |
10988284 |
wadissimo |
C |
May 3, 2015, 5:53 p.m. |
OK |
Java 7 |
TESTS |
65 |
77 |
0 |
|
2000 |
10987047 |
miguelmaurizio |
C |
May 3, 2015, 5:08 p.m. |
OK |
Java 7 |
TESTS |
65 |
77 |
0 |
|
2000 |
10986718 |
PlayLikeNeverB4 |
C |
May 3, 2015, 4:57 p.m. |
OK |
Java 7 |
TESTS |
65 |
77 |
0 |
|
2000 |
11271287 |
Sumeet.Varma |
C |
May 25, 2015, 10:23 p.m. |
OK |
Java 7 |
TESTS |
65 |
78 |
0 |
|
2000 |
10988109 |
karan173 |
C |
May 3, 2015, 5:47 p.m. |
OK |
Java 7 |
TESTS |
65 |
78 |
0 |
|
2000 |
10986931 |
AkshajK |
C |
May 3, 2015, 5:04 p.m. |
OK |
Java 7 |
TESTS |
65 |
78 |
0 |
|
2000 |
10986106 |
dusty.and.rusty |
C |
May 3, 2015, 4:39 p.m. |
OK |
Java 7 |
TESTS |
65 |
78 |
0 |
|
2000 |
10985648 |
uwi |
C |
May 3, 2015, 4:25 p.m. |
OK |
Java 7 |
TESTS |
65 |
78 |
0 |
|
2000 |
10997358 |
peter31415 |
C |
May 4, 2015, 3:53 p.m. |
OK |
Java 7 |
TESTS |
65 |
92 |
0 |
|
2000 |
13190548 |
alibaba |
C |
Sept. 23, 2015, 3:33 p.m. |
OK |
Java 8 |
TESTS |
65 |
109 |
0 |
|
2000 |
11274887 |
dhrumil140396 |
C |
May 26, 2015, 7:31 a.m. |
OK |
Java 8 |
TESTS |
65 |
109 |
0 |
|
2000 |
10997391 |
wistful23 |
C |
May 4, 2015, 3:57 p.m. |
OK |
Java 8 |
TESTS |
65 |
109 |
0 |
|
2000 |
10992984 |
Guliash |
C |
May 4, 2015, 6:25 a.m. |
OK |
Java 8 |
TESTS |
65 |
109 |
0 |
|
2000 |
10989330 |
kraskevich |
C |
May 3, 2015, 6:26 p.m. |
OK |
Java 8 |
TESTS |
65 |
109 |
0 |
|
2000 |
10987931 |
Sinner |
C |
May 3, 2015, 5:40 p.m. |
OK |
Java 8 |
TESTS |
65 |
109 |
0 |
|
2000 |
10986999 |
Slamur |
C |
May 3, 2015, 5:07 p.m. |
OK |
Java 8 |
TESTS |
65 |
109 |
0 |
|
2000 |
10986746 |
vadimmm |
C |
May 3, 2015, 4:58 p.m. |
OK |
Java 8 |
TESTS |
65 |
109 |
0 |
|
2000 |
30211043 |
Imaginary |
C |
Sept. 8, 2017, 7 p.m. |
OK |
Java 8 |
TESTS |
65 |
124 |
0 |
|
2000 |
12081721 |
savori |
C |
July 16, 2015, 9:46 a.m. |
OK |
Java 8 |
TESTS |
65 |
124 |
0 |
|
2000 |
10990422 |
bayleef |
C |
May 3, 2015, 7:25 p.m. |
OK |
MS C# |
TESTS |
65 |
46 |
307200 |
|
2000 |
10986546 |
haitao |
C |
May 3, 2015, 4:52 p.m. |
OK |
MS C# |
TESTS |
65 |
46 |
409600 |
|
2000 |
10995559 |
azukun |
C |
May 4, 2015, 12:15 p.m. |
OK |
MS C# |
TESTS |
65 |
62 |
3481600 |
|
2000 |
18858213 |
abtest100 |
C |
July 2, 2016, 6:22 p.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
14999709 |
ipavlov glebushka98 |
C |
Dec. 25, 2015, 8:33 a.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
14437689 |
poopi |
C |
Nov. 24, 2015, 10:22 a.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
14422800 |
poopi |
C |
Nov. 23, 2015, 7:39 a.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
11673359 |
NotImplemented |
C |
June 19, 2015, 6:50 p.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
11626156 |
pacu |
C |
June 17, 2015, 10:54 p.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
11375012 |
sister_what_hate_most |
C |
June 1, 2015, 9:07 a.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
11266260 |
chemthan |
C |
May 25, 2015, 2:32 p.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
10997963 |
Sunnat |
C |
May 4, 2015, 5:11 p.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
10991296 |
kingmoshe |
C |
May 3, 2015, 9:49 p.m. |
OK |
MS C++ |
TESTS |
65 |
15 |
0 |
|
2000 |
13322307 |
Ringod |
C |
Sept. 30, 2015, 8:18 p.m. |
OK |
PyPy 3 |
TESTS |
65 |
109 |
409600 |
|
2000 |
59603504 |
pr3pony |
C |
Aug. 28, 2019, 7:35 a.m. |
OK |
PyPy 3 |
TESTS |
65 |
140 |
0 |
|
2000 |
27315862 |
tommyricardo |
C |
May 24, 2017, 7:18 a.m. |
OK |
Python 2 |
TESTS |
65 |
62 |
0 |
|
2000 |
27315496 |
tommyricardo |
C |
May 24, 2017, 6:54 a.m. |
OK |
Python 2 |
TESTS |
65 |
62 |
0 |
|
2000 |
10985924 |
stjepan |
C |
May 3, 2015, 4:35 p.m. |
OK |
Python 2 |
TESTS |
65 |
62 |
0 |
|
2000 |
10985472 |
YuukaKazami |
C |
May 3, 2015, 4:19 p.m. |
OK |
Python 2 |
TESTS |
65 |
62 |
0 |
|
2000 |
10996692 |
scotter |
C |
May 4, 2015, 2:22 p.m. |
OK |
Python 2 |
TESTS |
65 |
62 |
102400 |
|
2000 |
10989417 |
roiti46 |
C |
May 3, 2015, 6:28 p.m. |
OK |
Python 2 |
TESTS |
65 |
77 |
0 |
|
2000 |
10985778 |
xyz2606 |
C |
May 3, 2015, 4:29 p.m. |
OK |
Python 2 |
TESTS |
65 |
77 |
102400 |
|
2000 |
11084788 |
iridescent |
C |
May 13, 2015, 2:05 a.m. |
OK |
Python 2 |
TESTS |
65 |
156 |
5324800 |
|
2000 |
10993935 |
MHR |
C |
May 4, 2015, 9:05 a.m. |
OK |
Python 2 |
TESTS |
65 |
576 |
0 |
|
2000 |
10987253 |
yurboss |
C |
May 3, 2015, 5:16 p.m. |
OK |
Python 3 |
TESTS |
65 |
61 |
307200 |
|
2000 |
10986383 |
ZhNV |
C |
May 3, 2015, 4:47 p.m. |
OK |
Python 3 |
TESTS |
65 |
62 |
0 |
|
2000 |
10986114 |
zetilovn |
C |
May 3, 2015, 4:39 p.m. |
OK |
Python 3 |
TESTS |
65 |
77 |
0 |
|
2000 |
10985981 |
Xellos |
C |
May 3, 2015, 4:36 p.m. |
OK |
Python 3 |
TESTS |
65 |
93 |
0 |
|
2000 |
11000574 |
ItsLastDay |
C |
May 4, 2015, 7:46 p.m. |
OK |
Python 3 |
TESTS |
65 |
93 |
819200 |
|
2000 |
67654374 |
NocturneBflat |
C |
Dec. 26, 2019, 1:22 p.m. |
OK |
Python 3 |
TESTS |
65 |
109 |
512000 |
|
2000 |
56772323 |
vjudge5 |
C |
July 9, 2019, 11:16 p.m. |
OK |
Python 3 |
TESTS |
65 |
124 |
0 |
|
2000 |
56760339 |
vjudge3 |
C |
July 9, 2019, 3:35 p.m. |
OK |
Python 3 |
TESTS |
65 |
139 |
0 |
|
2000 |
10985890 |
ichyo |
C |
May 3, 2015, 4:33 p.m. |
OK |
Python 3 |
TESTS |
65 |
140 |
5836800 |
|
2000 |
42135986 |
Mk_Python_v1 |
C |
Aug. 26, 2018, 11:56 p.m. |
OK |
Python 3 |
TESTS |
65 |
155 |
0 |
|
2000 |
remove filters
Back to search problems