結果

問題 No.613 Solitude by the window
ユーザー cielciel
提出日時 2017-12-14 08:36:54
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 275 bytes
コンパイル時間 50 ms
コンパイル使用メモリ 11,276 KB
実行使用メモリ 15,324 KB
最終ジャッジ日時 2023-08-21 04:01:24
合計ジャッジ時間 3,137 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,292 KB
testcase_01 AC 83 ms
15,116 KB
testcase_02 AC 86 ms
15,124 KB
testcase_03 AC 83 ms
15,172 KB
testcase_04 AC 84 ms
15,040 KB
testcase_05 AC 83 ms
15,084 KB
testcase_06 AC 83 ms
15,232 KB
testcase_07 AC 83 ms
15,120 KB
testcase_08 AC 83 ms
15,152 KB
testcase_09 AC 84 ms
15,180 KB
testcase_10 AC 83 ms
15,044 KB
testcase_11 AC 83 ms
15,252 KB
testcase_12 AC 83 ms
15,312 KB
testcase_13 AC 83 ms
15,092 KB
testcase_14 AC 83 ms
15,292 KB
testcase_15 AC 82 ms
15,144 KB
testcase_16 AC 83 ms
15,324 KB
testcase_17 AC 83 ms
15,156 KB
testcase_18 AC 82 ms
15,232 KB
testcase_19 AC 83 ms
15,296 KB
testcase_20 AC 82 ms
15,040 KB
testcase_21 AC 83 ms
15,268 KB
testcase_22 AC 83 ms
15,116 KB
testcase_23 AC 84 ms
15,152 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def pow(x,y,m)
	z=1
	while y>0
		z=z*x%m if y%2>0
		x=x*x%m
		y/=2
	end
	z
end
k,M=gets.split.map &:to_i
k=pow(2,k,M*M-1)
def mul(a,b)
	[(a[0]*b[0]+3*a[1]*b[1])%M,(a[1]*b[0]+b[1]*a[0])%M]
end
x=[2,1]
e=[1,0]
while k>0
	e=mul(e,x) if k%2>0
	x=mul(x,x)
	k/=2
end
p (2*e[0]-2)%M
0