結果

問題 No.167 N^M mod 10
ユーザー kyabariakyabaria
提出日時 2018-09-15 19:40:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 538 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 164,228 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 08:43:53
合計ジャッジ時間 3,787 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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