結果

問題 No.167 N^M mod 10
ユーザー Lycoris_iLycoris_i
提出日時 2015-09-13 02:09:12
言語 Ruby
(3.3.0)
結果
AC  
実行時間 77 ms / 1,000 ms
コード長 667 bytes
コンパイル時間 384 ms
コンパイル使用メモリ 11,920 KB
実行使用メモリ 16,100 KB
最終ジャッジ日時 2023-10-21 23:54:56
合計ジャッジ時間 3,976 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

n = gets.to_i % 10
m = gets.to_i
if m == 0
  puts 1
  exit
end
case n
when 0, 1, 5, 6
  puts n
when 2
  case m % 4
  when 1
    puts 2
  when 2
    puts 4
  when 3
    puts 8
  when 0
    puts 6
  end
when 3
  case m % 4
  when 1
    puts 3
  when 2
    puts 9
  when 3
    puts 7
  when 0
    puts 1
  end
when 4
  case m % 4
  when 1, 3
    puts 4
  when 0, 2
    puts 6
  end
when 7
  case m % 4
  when 1
    puts 7
  when 2
    puts 9
  when 3
    puts 3
  when 0
    puts 1
  end
when 8
  case m % 4
  when 1
    puts 8
  when 2
    puts 4
  when 3
    puts 2
  when 0
    puts 6
  end
when 9
  case m % 4
  when 1, 3
    puts 9
  when 0, 2
    puts 1
  end
end
0