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