結果

問題 No.2007 Arbitrary Mod (Easy)
コンテスト
ユーザー taisii2
提出日時 2022-07-15 21:33:49
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 405 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,120 ms
コンパイル使用メモリ 184,012 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-15 18:29:24
合計ジャッジ時間 3,710 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 8 WA * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
long long pow(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans *= a;
    }
    a *= a;
    b /= 2;
  }
  return ans;
}
int main() {
  long long a, n;
  cin >> a >> n;
  long long mod = a;
  int c = 1;
  while (mod < 1E7) {
    mod *= a;
    c++;
  }
  n %= c;
  cout << mod << endl;
  cout << pow(a, n) << endl;
}
0