結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2015-04-04 19:11:35 |
言語 | Ruby (3.4.1) |
結果 |
RE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 343 bytes |
コンパイル時間 | 191 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-09-22 01:13:31 |
合計ジャッジ時間 | 3,700 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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