結果

問題 No.167 N^M mod 10
ユーザー Mister
提出日時 2020-04-12 14:17:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 599 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 71,604 KB
最終ジャッジ日時 2025-01-09 17:41:19
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>

void solve() {
    std::string s, t;
    std::cin >> s >> t;

    std::reverse(s.begin(), s.end());
    s.resize(1);
    std::reverse(s.begin(), s.end());

    std::reverse(t.begin(), t.end());
    t.resize(2, '0');
    std::reverse(t.begin(), t.end());

    int n = std::stoi(s),
        m = std::stoi(t);

    int ans = 1;
    for (int i = 0; i < m; ++i) {
        (ans *= n) %= 10;
    }

    std::cout << ans << std::endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0