結果

問題 No.167 N^M mod 10
ユーザー tshigtshig
提出日時 2016-08-09 10:47:07
言語 Ruby
(3.3.0)
結果
AC  
実行時間 82 ms / 1,000 ms
コード長 518 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 11,924 KB
実行使用メモリ 16,132 KB
最終ジャッジ日時 2023-10-22 00:09:13
合計ジャッジ時間 4,185 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
16,124 KB
testcase_01 AC 71 ms
16,132 KB
testcase_02 AC 75 ms
16,132 KB
testcase_03 AC 74 ms
16,132 KB
testcase_04 AC 81 ms
16,132 KB
testcase_05 AC 82 ms
16,132 KB
testcase_06 AC 76 ms
16,128 KB
testcase_07 AC 77 ms
16,132 KB
testcase_08 AC 75 ms
16,132 KB
testcase_09 AC 72 ms
16,132 KB
testcase_10 AC 73 ms
16,132 KB
testcase_11 AC 73 ms
16,132 KB
testcase_12 AC 71 ms
16,132 KB
testcase_13 AC 74 ms
16,132 KB
testcase_14 AC 74 ms
16,132 KB
testcase_15 AC 72 ms
16,132 KB
testcase_16 AC 75 ms
16,132 KB
testcase_17 AC 74 ms
16,132 KB
testcase_18 AC 71 ms
16,132 KB
testcase_19 AC 73 ms
16,132 KB
testcase_20 AC 74 ms
16,132 KB
testcase_21 AC 74 ms
16,132 KB
testcase_22 AC 71 ms
16,132 KB
testcase_23 AC 69 ms
16,132 KB
testcase_24 AC 71 ms
16,132 KB
testcase_25 AC 71 ms
16,132 KB
testcase_26 AC 71 ms
16,132 KB
testcase_27 AC 72 ms
16,132 KB
testcase_28 AC 71 ms
16,132 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Calc0167
  def initialize(args)
    args = args.map { |l| l.chomp.split(/\s+/) }
    @n = args.shift.first
    @m = args.shift.first
  end

  TABLE = [
    [0],
    [1],
    [6, 2, 4, 8],
    [1, 3, 9, 7],
    [6, 4],
    [5],
    [6],
    [1, 7, 9, 3],
    [6, 8, 4, 2],
    [1, 9]
  ]

  def run
    n = @n[-1..-1].to_i
    m = (@m.size == 1 ? @m : @m[-2..-1]).to_i
    if @m == '0'
      1
    else
      TABLE[n][m % TABLE[n].size]
    end
  end
end

puts Calc0167.new(STDIN.readlines).run if __FILE__ == $0
0