結果

問題 No.167 N^M mod 10
ユーザー kyabaria
提出日時 2018-09-15 19:40:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 538 bytes
コンパイル時間 1,463 ms
コンパイル使用メモリ 168,144 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-18 07:10:05
合計ジャッジ時間 2,949 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 6 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef  long long ll;
#define INF 1000000000
using namespace std;
#define MOD 1000000007
int main(void){
    string n,m;
    cin>>n>>m;
    ll size_n=n.size(),size_m=m.size();
    int ans;
    int p=n[n.size()-1]-'0',q=stoi(m.substr(m.size()-2,2));
    //cout<<p<<" "<<q<<endl;
    int num[10][4]={{0,0,0,0},{1,1,1,1},{2,4,8,6},{3,9,7,1},{4,6,4,6},{5,5,5,5},{6,6,6,6},{7,9,3,1},{8,4,2,6},{9,1,9,1}};
    int m4=(q-1)%4;
    if(q==0){
        ans=1;
    }else{
        ans=num[p][m4];
    }
    cout<<ans<<endl;
}
0