結果
問題 |
No.167 N^M mod 10
|
ユーザー |
|
提出日時 | 2016-11-20 23:19:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 420 bytes |
コンパイル時間 | 1,553 ms |
コンパイル使用メモリ | 166,740 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-27 09:14:00 |
合計ジャッジ時間 | 2,256 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 WA * 2 |
ソースコード
#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; if( x == 0 ) x = m; int ans = 1; for( int i = 0; i < x; ++i ) ans = ans * ld % 10; cout << ans << endl; return 0; }