結果
問題 |
No.167 N^M mod 10
|
ユーザー |
👑 |
提出日時 | 2020-01-09 23:58:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 427 bytes |
コンパイル時間 | 547 ms |
コンパイル使用メモリ | 65,220 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-23 05:06:48 |
合計ジャッジ時間 | 1,376 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 8 WA * 19 |
ソースコード
#include <iostream> using namespace std; int main(){ string n,m;cin>>n>>m; if(m == "0"){ cout << 0 << endl; return 0; } int N = n[n.size()-1]-'0'; int M; if(m.size() == 1){ M = m[0]-'0'; }else{ M = (m[m.size()-2]-'0')*10 + m[m.size()-1]-'0'; } M %= 4; int ans = N; for(int i = 0; M > i; i++){ ans = (N*ans)%10; } cout << ans << endl; }