結果
問題 |
No.167 N^M mod 10
|
ユーザー |
![]() |
提出日時 | 2018-02-15 00:13:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 638 bytes |
コンパイル時間 | 664 ms |
コンパイル使用メモリ | 79,816 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 11:23:51 |
合計ジャッジ時間 | 2,213 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 WA * 8 RE * 3 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <cstring> #include <math.h> #include <cmath> #include <limits.h> #include <map> #include <set> #include <queue> #include <algorithm> #include <functional> #include <stdio.h> using namespace std; long long MOD = 1000000007; int main() { string N,M; cin >> N >> M; if ( M == "0" ) { cout << 1 << endl; return 0; } int a = N[N.length()-1] - '0'; int b[4]; int n = a; for ( int i = 0; i < 4; i++ ) { b[i] = n; n *= a; n %= 10; } cout << b[stoi(M.substr(M.length()-2,2))%4 - 1] << endl; return 0; }