結果
問題 |
No.747 循環小数N桁目 Hard
|
ユーザー |
|
提出日時 | 2020-10-02 00:54:56 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 315 bytes |
コンパイル時間 | 97 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 13,056 KB |
最終ジャッジ日時 | 2024-07-07 12:39:43 |
合計ジャッジ時間 | 14,490 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 51 WA * 69 |
コンパイルメッセージ
Syntax OK
ソースコード
n = gets.chomp k = gets.chomp def pow_mod6(n, k) k2 = k[-1].to_i % 2 if k.length <= 1 && k[-1] <= '2' k2 = k.to_i end n2 = n[-1].to_i % 2 n3 = n.each_char.map(&:to_i).sum % 3 n6 = 3*n2 + n3 if n.length <= 1 && n[-1] <= '6' n6 = n.to_i end n6.pow(k2, 6) end puts '428571'[pow_mod6(n, k)]