結果

問題 No.167 N^M mod 10
ユーザー mnr
提出日時 2020-03-06 08:46:15
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 270 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 165,344 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-14 02:37:56
合計ジャッジ時間 2,312 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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