結果

問題 No.167 N^M mod 10
ユーザー mencottonmencotton
提出日時 2020-11-02 22:45:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 69,400 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 13:58:33
合計ジャッジ時間 2,384 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 7 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 6 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 14 ms
4,380 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 9 ms
4,376 KB
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;

int main() {
    string n, m;
    cin >> n >> m;
    if (m == "0")cout << 1 << endl;
    else {
        int x = n.back() - '0';
        int y = 0;
        for (int i = m.size() - 1; i >= 0; i--) {
            y *= 10, y %= 3628800;
            y += m[i] - '0', y %= 3628800;
        }

        if (y == 0)y = 3628800;

        int ret = 1;
        for (int i = 0; i < y; i++) ret *= x, ret %= 10;
        cout << ret << endl;
    }
    return 0;
}
0