結果

問題 No.167 N^M mod 10
ユーザー tsuishitsuishi
提出日時 2020-12-29 13:56:15
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 731 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 29,696 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 14:52:06
合計ジャッジ時間 1,646 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 0 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
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 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1 ms
5,376 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#define DEBUGe

#define NOP do{}while(0)

#ifdef DEBUG
#define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0)
#define TRACECR do{printf("\n");fflush(stdout);}while(0)
#else
#define TRACE(...) NOP
#define TRACECR NOP
#endif
//#define MOD    (1000000007)
#define MOD    (10)

int main( void ) {
    long    aa;
    long    bb;
    long    cc;

    scanf("%ld", &aa );
    scanf("%ld", &bb );
    if( bb == 0 ) {
        printf("%d\n", 0);
        return 0;
    } else if( bb == 1 ) {
        printf("%d\n", aa % 10);
        return 0;
    }
    aa %= 10;
    bb %= 4;
    cc = aa;
    for(int i = 1; i < bb; i++) {
        cc = (cc * aa) %10;
    }
    cc %= 10;
    printf("%d\n", cc);
    return 0;
}
0