結果

問題 No.303 割れません
ユーザー 👑 hos.lyrichos.lyric
提出日時 2019-01-18 09:37:47
言語 Ruby
(3.3.0)
結果
AC  
実行時間 181 ms / 10,000 ms
コード長 234 bytes
コンパイル時間 45 ms
コンパイル使用メモリ 11,556 KB
実行使用メモリ 21,604 KB
最終ジャッジ日時 2023-09-18 15:06:28
合計ジャッジ時間 3,534 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,256 KB
testcase_01 AC 83 ms
15,144 KB
testcase_02 AC 83 ms
15,092 KB
testcase_03 AC 118 ms
17,912 KB
testcase_04 AC 166 ms
20,012 KB
testcase_05 AC 163 ms
19,780 KB
testcase_06 AC 164 ms
19,732 KB
testcase_07 AC 176 ms
21,016 KB
testcase_08 AC 179 ms
21,580 KB
testcase_09 AC 181 ms
21,540 KB
testcase_10 AC 84 ms
15,244 KB
testcase_11 AC 168 ms
19,704 KB
testcase_12 AC 180 ms
21,604 KB
testcase_13 AC 133 ms
18,904 KB
testcase_14 AC 116 ms
17,996 KB
testcase_15 AC 99 ms
17,108 KB
testcase_16 AC 82 ms
15,152 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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) ? [3, :INF] : [L, (L % 2 == 0) ? (2 * p * q) : q]
0