結果
問題 |
No.167 N^M mod 10
|
ユーザー |
![]() |
提出日時 | 2015-03-23 07:08:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 396 bytes |
コンパイル時間 | 390 ms |
コンパイル使用メモリ | 57,208 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-29 00:22:19 |
合計ジャッジ時間 | 1,111 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 WA * 3 |
ソースコード
#include <iostream> #include <string> using namespace std; int getnum(char c){ return c - '0'; } int main() { string N, M; cin >> N >> M; int a = getnum(N[N.size() - 1]); int b = getnum(M[M.size() - 1]); if (M.size() != 1) b += getnum(M[M.size() - 2]) * 10; if (M.size() != 3) b += 100; int ans = 1; for (int i = 0; i < b; i++) { ans *= a; ans %= 10; } cout << ans << endl; }