結果

問題 No.344 ある無理数の累乗
ユーザー tottoripapertottoripaper
提出日時 2016-05-01 22:36:59
言語 Ruby
(3.3.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 289 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 11,332 KB
実行使用メモリ 15,880 KB
最終ジャッジ日時 2023-08-27 01:37:51
合計ジャッジ時間 5,473 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
15,844 KB
testcase_01 AC 101 ms
15,784 KB
testcase_02 AC 100 ms
15,712 KB
testcase_03 AC 103 ms
15,712 KB
testcase_04 AC 101 ms
15,656 KB
testcase_05 AC 102 ms
15,712 KB
testcase_06 AC 101 ms
15,560 KB
testcase_07 AC 102 ms
15,868 KB
testcase_08 AC 101 ms
15,792 KB
testcase_09 AC 101 ms
15,724 KB
testcase_10 AC 104 ms
15,708 KB
testcase_11 AC 102 ms
15,696 KB
testcase_12 AC 104 ms
15,768 KB
testcase_13 AC 101 ms
15,880 KB
testcase_14 AC 100 ms
15,828 KB
testcase_15 AC 100 ms
15,720 KB
testcase_16 AC 103 ms
15,696 KB
testcase_17 AC 102 ms
15,828 KB
testcase_18 AC 98 ms
15,792 KB
testcase_19 AC 100 ms
15,656 KB
testcase_20 AC 99 ms
15,644 KB
testcase_21 AC 100 ms
15,708 KB
testcase_22 AC 99 ms
15,732 KB
testcase_23 AC 100 ms
15,856 KB
testcase_24 AC 100 ms
15,680 KB
testcase_25 AC 98 ms
15,852 KB
testcase_26 AC 101 ms
15,696 KB
testcase_27 AC 102 ms
15,836 KB
testcase_28 AC 101 ms
15,716 KB
testcase_29 AC 100 ms
15,588 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'matrix'

class Matrix
  def % d; map{|e| e % d} end
end

m = Matrix[[1, 3], [1, 1]]
l = Matrix.I(2)

n = gets.chomp.to_i
_n = n

while _n > 0 do
  l = l * m % 1000 if (_n & 1) == 1
  _n >>= 1
  m = m * m % 1000
end

print (l[0, 0] * 2 % 1000 + (n % 2 == 0 ? 999 : 0)) % 1000
puts
0