結果
| 問題 | No.167 N^M mod 10 |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2015-04-04 19:11:35 |
| 言語 | Ruby (4.0.6 + ACL) |
| 結果 |
RE
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 343 bytes |
| 記録 | |
| コンパイル時間 | 9 ms |
| コンパイル使用メモリ | 9,696 KB |
| 実行使用メモリ | 22,272 KB |
| 最終ジャッジ日時 | 2026-09-02 01:44:29 |
| 合計ジャッジ時間 | 4,701 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 2 |
| other | RE * 27 |
コンパイルメッセージ
Syntax OK
ソースコード
class Fixnum
MOD = 10
def power(x)
result = 1
n = self
while x > 0
result = (result * n) % MOD if (x & 1).nonzero?
n = (n * n) % MOD
x >>= 1
end
result
end
end
class Yukicoder
def initialize
n = gets.chomp.to_i
m = gets.chomp.to_i
puts n.power(m) % 10
end
end
Yukicoder.new
siman