結果
問題 |
No.167 N^M mod 10
|
ユーザー |
|
提出日時 | 2016-11-20 23:15:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 398 bytes |
コンパイル時間 | 1,732 ms |
コンパイル使用メモリ | 167,060 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-27 09:13:51 |
合計ジャッジ時間 | 2,415 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 17 WA * 10 |
ソースコード
#include <bits/stdc++.h> using namespace std; signed main(){ string N, M; cin >> N >> M; int ld = N.back() - '0'; int m = 1; for( int i = ld * ld % 10; i != ld; i = i * ld % 10 ) ++m; int x = 0; for( int i = 0; i < M.size(); ++i ) x = x * 10 + M[ i ] - '0', x %= m; int ans = 1; for( int i = 0; i < x; ++i ) ans = ans * ld % 10; cout << ans << endl; return 0; }