結果

問題 No.167 N^M mod 10
ユーザー firiexp
提出日時 2018-07-26 18:49:29
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 376 bytes
コンパイル時間 499 ms
コンパイル使用メモリ 66,656 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-01 03:23:02
合計ジャッジ時間 1,389 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using ll = long long;
using namespace std;

int main() {
    string n, m;
    int a, b = 1;
    cin >> n >> m;

    a = n.back()- '0';
    int ans = a;
    b = (stoi(m.substr(m.size() >= 2? m.size()-2 : 0) ) -1 ) % 4 + 1;
    for (int i = 1; i < b; ++i) {
        ans =(ans * a)%10;
    }
    if (m == "0") ans = 1;
    cout << ans << "\n";
    return 0;
}
0