結果

問題 No.303 割れません
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-18 09:36:52
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 234 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 11,392 KB
実行使用メモリ 21,508 KB
最終ジャッジ日時 2023-09-18 15:03:50
合計ジャッジ時間 3,952 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,368 KB
testcase_01 AC 83 ms
15,064 KB
testcase_02 AC 83 ms
15,256 KB
testcase_03 AC 141 ms
17,788 KB
testcase_04 AC 167 ms
20,036 KB
testcase_05 AC 166 ms
19,904 KB
testcase_06 AC 165 ms
20,060 KB
testcase_07 AC 175 ms
21,084 KB
testcase_08 AC 181 ms
21,476 KB
testcase_09 AC 179 ms
21,472 KB
testcase_10 WA -
testcase_11 AC 166 ms
19,976 KB
testcase_12 AC 180 ms
21,508 KB
testcase_13 AC 135 ms
18,976 KB
testcase_14 AC 115 ms
18,140 KB
testcase_15 AC 103 ms
17,128 KB
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

L = gets.to_i
p, q = 1, 0
l = (L % 2 == 0) ? (L / 2) : L
21.downto(0) { |h|
  p, q = p * p + q * q, 2 * p * q + q * q
  if ((l >> h) & 1) != 0 then p, q = q, p + q end
}
puts (L == 2) ? [q, :INF] : [L, (L % 2 == 0) ? (2 * p * q) : q]
0