結果
| 問題 |
No.167 N^M mod 10
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2015-04-04 19:13:34 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 185 ms / 1,000 ms |
| コード長 | 344 bytes |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 35,072 KB |
| 最終ジャッジ日時 | 2024-09-22 01:13:45 |
| 合計ジャッジ時間 | 4,906 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 27 |
コンパイルメッセージ
Syntax OK
ソースコード
class Numeric
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