結果

問題 No.167 N^M mod 10
コンテスト
ユーザー mnr
提出日時 2020-03-02 13:59:29
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 243 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 958 ms
コンパイル使用メモリ 179,524 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2026-05-01 08:04:30
合計ジャッジ時間 2,084 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
  int N; int M;
  cin >> N;
  cin >> M;
  int n = N % 10;
  int A = n;
  for (int i = 0; i < M-1; i++) {
    A *= n;
    if (A >= 10) {
      A %= 10;
    }
  }
  cout << A << endl;
}
0