結果
問題 |
No.167 N^M mod 10
|
ユーザー |
![]() |
提出日時 | 2016-02-16 10:48:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 394 bytes |
コンパイル時間 | 429 ms |
コンパイル使用メモリ | 56,392 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 07:16:32 |
合計ジャッジ時間 | 1,320 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 WA * 6 |
ソースコード
#include <iostream> #include <string> using namespace std; int main() { string nstr, mstr; cin >> nstr >> mstr; int n = atoi(&nstr.back()); int m = (mstr.length() > 2) ? stoi(mstr.substr(mstr.size()-2,2)) : stoi(mstr); m = (m == 0) ? 0 : (m-1) % 4 + 1; int ans = 1; for (int i = 0; i < m; i++) ans = (ans * n) % 10; cout << ans << endl; return 0; }