結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2016-02-16 11:02:47 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 416 bytes |
コンパイル時間 | 483 ms |
コンパイル使用メモリ | 56,448 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 01:27:49 |
合計ジャッジ時間 | 1,375 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 27 |
ソースコード
#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 = (mstr.length() == 1 && m == 0) ? 0 : (m+3) % 4 + 1;int ans = 1;for (int i = 0; i < m; i++)ans = (ans * n) % 10;cout << ans << endl;return 0;}