結果

問題 No.167 N^M mod 10
ユーザー 0w10w1
提出日時 2016-11-20 23:14:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 379 bytes
コンパイル時間 1,739 ms
コンパイル使用メモリ 166,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-05-05 12:06:18
合計ジャッジ時間 3,790 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0