結果

問題 No.167 N^M mod 10
ユーザー BantakoBantako
提出日時 2017-07-07 21:38:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,188 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 23,552 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 01:17:03
合計ジャッジ時間 1,073 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 0 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    3 | main(){
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%s %s",N,M);
      |     ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<string.h>
main(){
    char N[10001];
    char M[10001];
    scanf("%s %s",N,M);
    if(strlen(M)==1){
        M[1] = M[0];
        M[0] = '0';
        M[2] = '\0';
    }
    int base = N[strlen(N)-1] - '0';
    int exp = (M[strlen(M)-2] - '0')*10 + M[strlen(M)-1] - '0';

    int ans;
    if(exp == 0){
        ans = 1;
    }else{
        if(base == 0){
            ans = 0;
        }
        if(base == 1){
            ans = 1;
        }
        if(base == 2){
            int num[] = {6,2,4,8};
            ans = num[exp%4];
        }
        if(base == 3){
            int num[] = {1,3,6,9,7};
            ans = num[exp%5];
        }
        if(base == 4){
            int num[] = {6,4};
            ans = num[exp%2];
        }
        if(base == 5){
            ans = 5;
        }
        if(base == 6){
            ans = 6;
        }
        if(base == 7){
            int num[] = {1,7,9,3};
            ans = num[exp%4];
        }
        if(base == 8){
            int num[] = {6,8,4,2};
            ans = num[exp%4];
        }
        if(base == 9){
            int num[] = {1,9};
            ans = num[exp%2];
        }
    }
    printf("%d\n",ans);

}
0