結果

問題 No.167 N^M mod 10
ユーザー tottoripaper
提出日時 2015-03-20 00:13:35
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 57,488 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-28 23:32:25
合計ジャッジ時間 1,319 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

// Ω\ζ°)チーン Ω\ζ°)チーン Ω\ζ°)チーン

#include <iostream>
#include <cstdio>

int main(){
    std::string S, T;
    std::cin >> S >> T;

    while(T.size() < 2){
        T = '0' + T;
    }
    
    int n = S[S.size()-1] - '0', m = (T[T.size()-2]-'0') * 10 + (T[T.size()-1]-'0');

    if(n == 0){
        std::cout << (T == "0" ? 1 : 0) << std::endl;
    }else{
        int res = 1;
        for(int i=0;i<m;i++){
            res = res * n % 10;
        }
        std::cout << res << std::endl;
    }
}
0