結果

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

ソースコード

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("1" + 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