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