結果

問題 No.167 N^M mod 10
ユーザー kyabariakyabaria
提出日時 2018-09-15 20:02:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 684 bytes
コンパイル時間 1,750 ms
コンパイル使用メモリ 167,876 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 00:24:39
合計ジャッジ時間 2,506 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 q;
    if(m.size()<2)q=stoi(m);
    else q=stoi(m.substr(m.size()-2,2));
    int p=n[n.size()-1]-'0';
    //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%4;
    if(m4!=0){
        m4--;
    }else{
        m4=3;
    }
    //cout<<p<<" "<<q<<" "<<m4<<endl;
    if(m=="0"){
        ans=1;
    }else{
        ans=num[p][m4];
    }
    cout<<ans<<endl;
}
0