結果

問題 No.167 N^M mod 10
ユーザー wk1080idwk1080id
提出日時 2019-01-02 16:41:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,747 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 83,060 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 00:25:48
合計ジャッジ時間 1,823 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 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 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 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 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


signed main(void) {
    int i,j;
    string s;
    string t;
    cin >> s;
    cin >> t;
    if(t == "0"){
        cout << 1 << endl;
        return 0;
    }
    int m = 100;
    if(t.size() == 1){
        m += t.back() - '0';
    }else{
        m += (t[t.size()-2]-'0')*10 + t.back() - '0';
    }
    m--;
    int ans;
    int v2[] = {2,4,8,6};
    int v3[] = {3,9,7,1};
    int v4[] = {4,6,4,6};
    int v7[] = {7,9,3,1};
    int v8[] = {8,4,2,6};
    int v9[] = {9,1,9,1};
    switch (s.back()) {
        case '0': ans = 0; break;
        case '1': ans = 1; break;
        case '2': ans = v2[m%4]; break;
        case '3': ans = v3[m%4]; break;
        case '4': ans = v4[m%4]; break;
        case '5': ans = 5; break;
        case '6': ans = 6; break;
        case '7': ans = v7[m%4]; break;
        case '8': ans = v8[m%4]; break;
        case '9': ans = v9[m%4]; break;
    }
    cout << ans << endl;
}
0