結果

問題 No.167 N^M mod 10
ユーザー eve__fuyuki
提出日時 2018-03-14 09:05:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 409 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 55,676 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-26 01:48:26
合計ジャッジ時間 1,349 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
using namespace std;
int main(){
    string N,M;
    int n,m,ans;
    cin >> N >> M;
    n = (int)N[N.length()-1]-48;
    if(M.length() < 2) m = stoi(M);
    else m = stoi(M.substr(M.length()-2));
    if(M == "0") ans = 1;
    else {
        ans = n;
        for(int i=1;i<m%4;i++){
            ans = ans * n % 10;
        }
    }
    cout << ans << endl;;
    return 0;
}
0