結果
問題 | No.167 N^M mod 10 |
ユーザー |
![]() |
提出日時 | 2020-06-04 19:03:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 399 bytes |
コンパイル時間 | 1,573 ms |
コンパイル使用メモリ | 165,968 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-29 22:14:02 |
合計ジャッジ時間 | 2,529 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 WA * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string N, M; cin >> N >> M; int n, m; n = N.back() - '0'; m = M.back() - '0'; if (M == "0") { cout << 1 << endl; return 0; } if (M.size() >= 2) { m += 10 * (int)(M[M.size() - 2] - '0'); } int ans = 1; while (m--) (ans *= n) %= 10; cout << ans << endl; }