結果
問題 | No.167 N^M mod 10 |
ユーザー |
|
提出日時 | 2018-10-07 20:40:19 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 1,807 bytes |
コンパイル時間 | 515 ms |
コンパイル使用メモリ | 64,768 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-22 01:48:44 |
合計ジャッジ時間 | 1,360 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 3 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 1 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 1 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 3 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 3 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
ソースコード
#include <iostream> #include <cstring> using namespace std; int main() { char N[10002], M[10002]; int N_length, M_length, tmp; cin >> N >> M; N_length = strlen(N); M_length = strlen(M); if (M[0] == '0') cout << 1; else if (N[N_length - 1] == '0') cout << 0; else { if (N[N_length - 1] == '1' || N[N_length - 1] == '5' || N[N_length - 1] == '6') cout << N[N_length - 1]; else if (N[N_length - 1] == '4' || N[N_length - 1] == '9') { if ((M[M_length - 1] - '0') % 2) cout << N[N_length - 1]; else { if (N[N_length - 1] == '4') cout << 6; else cout << 1; } } else { if (M_length == 1) tmp = M[0] - '0'; else tmp = 10 * (M[M_length - 2] - '0') + M[M_length - 1] - '0'; if (N[N_length - 1] == '2') { if (tmp % 4 == 1) cout << 2; else if (tmp % 4 == 2) cout << 4; else if (tmp % 4 == 3) cout << 8; else cout << 6; } else if (N[N_length - 1] == '3') { if (tmp % 4 == 1) cout << 3; else if (tmp % 4 == 2) cout << 9; else if (tmp % 4 == 3) cout << 7; else cout << 1; } else if (N[N_length - 1] == '7') { if (tmp % 4 == 1) cout << 7; else if (tmp % 4 == 2) cout << 9; else if (tmp % 4 == 3) cout << 3; else cout << 1; } else { if (tmp % 4 == 1) cout << 8; else if (tmp % 4 == 2) cout << 4; else if (tmp % 4 == 3) cout << 2; else cout << 6; } } } }