Modular Inverse

Submit

Your name:
File:
Open code-statistics:

Language is selected by the extension of the file. See the list of supported languages to know the extension of your language.

Problem

In each line, natural numbers A and M are given.
Find a natural number X that satisfies
X < M
and
A X = 1 (mod M).

-- tails

Options

exec is denied

rejudge feature is enabled

now post-mortem time, all source codes will be revealed

Sample input:_

30519981 43671272
11404136 28064289
67728489 82422718
5477269 99479486
10780576 47157031
16124927 16911852
9173354 40690679
6716901 21496895
10975919 39008580
17096025 82100002
61092727 63442710
43794609 53167420
37356283 39148774
5736858 11708545
56794189 58927985
69068722 89712195
17388073 58545793
1480509 2507299
25990957 56526286
19288237 27426279
70342035 99585124
1422111 7100245
34428635 38831031
38448139 91636489
17812676 45261329
45284637 61760807
22433433 86098528
40202329 67911174
12324507 15570541
23187044 24781063
93479448 94752569
29282527 74113178
71489774 93376059
69016544 90665469
46387501 89744223
31430421 60001378
13340587 51398972
16765535 17145012
18274904 76715189
41075546 52769897
9397893 18112918
41156563 69654581
1798701 86232562
10901715 39066691
7853029 27956470
18139123 83937021
46079042 54229643
25742869 90463813
34146613 48147700
441613 54163009
88526366 94541111
11980515 50393554
25002823 55584472
52368958 54711947
8787992 90968411
2101667 98010630
31263329 63392002
32929933 71915994
65731633 67235125
25140571 93501003
24010557 74667400
42103355 54090062
9321563 66458810
72324573 81194405
8023835 19668814
8247761 56060782
4293097 5382828
30105836 73433533
4283219 6027999
19222459 41005159
7529316 50270917
8594926 16362847
30523399 44160827
3531223 16849437
2345362 30519389
31558207 57284317
39150217 41312630
26179742 33703741
24143199 28962908
18955094 36008413
63310532 97907493
23649095 30003931
43019870 56250181
25139372 51164845
15500893 18130769
38137679 60201775
21099289 40227992
31456830 37715993
52532879 79337691
20153863 60864834
713181 767726
87992991 99812542
7989643 36475040
1824331 2305667
2816737 24189909
34078441 51985713
2798737 44405756
22415165 52821993
33857938 48637973
41612569 44098194

Sample output:

38920925
25776902
34876371
58427479
31375304
10362731
21426544
2891431
6646079
18358957
30388603
13328949
8171575
9030222
23063564
58909228
25438414
492061
43627021
18552562
96285823
2685146
12229766
56857147
2819408
51671712
25850633
60968527
14260322
952194
76020211
59086851
48253001
18082394
22628860
25266805
20534211
12731135
76466790
13243177
14829443
22496355
25350499
12919218
11323959
12470035
25107631
79107825
4219777
34491230
64286610
33915301
49736303
44775202
57752665
51659273
55878897
33138097
53814547
27316765
47693493
24560047
9904317
24724842
10124061
39848279
5073565
53424601
1240919
14370619
39703925
14282562
28404844
8899114
20949114
22608355
5540643
8714976
6014535
25351748
20444402
12445541
49857292
19640153
11424033
54371044
20154457
11629498
65510948
57134713
194743
46779043
32314627
458335
10918912
11940853
254893
20735615
44151565
10170709

Ranking

Ruby _

RankUserSizeTimeDateStatistics
1mitchs490.03812016/12/30 04:05:230B / 34B / 11B
2teebee490.03962016/12/30 08:39:040B / 34B / 11B
3rotary-o490.03442016/12/30 20:04:350B / 34B / 11B

Ruby2 _

RankUserSizeTimeDateStatistics
1mitchs510.10272016/12/30 04:07:350B / 34B / 14B
2teebee510.07952016/12/30 08:44:150B / 34B / 14B
3rotary-o510.08042016/12/30 20:33:480B / 34B / 14B

Perl _

RankUserSizeTimeDateStatistics
1tails440.09212016/12/29 18:43:200B / 23B / 17B
2teebee440.07072016/12/30 07:24:310B / 23B / 17B

Python _

RankUserSizeTimeDateStatistics
1mitchs960.05272016/12/31 04:57:370B / 57B / 30B
2xnor960.03152016/12/31 07:51:490B / 57B / 30B
3hallvabo980.03702016/12/30 08:26:040B / 58B / 32B
4xsot980.03102017/01/08 12:09:460B / 58B / 31B
5rolf1240.04672016/12/31 03:36:060B / 74B / 39B
6mitchs (henkma)800.02552017/01/12 21:20:220B / 51B / 24B

Python3 _

RankUserSizeTimeDateStatistics
1kimiyuki1160.05792016/12/30 18:42:530B / 68B / 38B

Clojure _

RankUserSizeTimeDateStatistics
1teebee540.82742016/12/30 09:31:280B / 34B / 18B

C _

RankUserSizeTimeDateStatistics
1tails950.01072017/01/12 16:13:050B / 45B / 50B
2nu970.01072017/01/03 00:59:230B / 45B / 52B
3rotary-o980.07052017/01/08 00:59:200B / 47B / 51B
4lpha990.01082017/01/08 05:14:370B / 47B / 52B
5%201090.01082017/01/03 23:06:460B / 51B / 58B

Haskell _

RankUserSizeTimeDateStatistics
1henkma800.02762017/01/09 14:57:120B / 52B / 23B

Java _

RankUserSizeTimeDateStatistics
1teebee1430.30282016/12/30 08:05:310B / 104B / 34B
2rotary-o1430.31382017/01/01 12:05:340B / 104B / 34B

Maxima _

RankUserSizeTimeDateStatistics
1teebee481.27912016/12/30 09:00:060B / 32B / 13B

Bash _

RankUserSizeTimeDateStatistics
1tails420.08732017/01/06 00:45:481B / 21B / 16B

Bash (builtins) _

RankUserSizeTimeDateStatistics
1tails700.19072017/01/12 15:03:370B / 28B / 32B
2tails680.19082017/01/13 15:48:290B / 27B / 35B

GolfScript _

RankUserSizeTimeDateStatistics
1tails380.23972017/01/05 00:35:100B / 15B / 23B
2mitchs320.18882017/01/20 00:54:140B / 9B / 23B

gs2 _

RankUserSizeTimeDateStatistics
1whio270.24422016/12/30 06:27:2012B / 12B / 1B

Groovy _

RankUserSizeTimeDateStatistics
1teebee721.08962016/12/30 09:24:500B / 44B / 26B

Scala _

RankUserSizeTimeDateStatistics
1rotary-o814.88762017/01/01 12:13:350B / 54B / 24B

Language Ranking_

RankLangUserSizeScore
1gs2whio2710000
2GolfScriptmitchs328437
3Bashtails426428
4Perltails446136
5Maximateebee485625
6Rubymitchs495510
7Ruby2mitchs515294
8Clojureteebee545000
9Bash (builtins)tails683970
10Groovyteebee723750
11Haskellhenkma803375
12Pythonmitchs (henkma)803375
13Scalarotary-o813333
14Ctails952842
15Python3kimiyuki1162327
16Javateebee1431888

return top