結果

問題 No.403 2^2^2
ユーザー playrollerplayroller
提出日時 2018-11-14 14:50:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,249 bytes
コンパイル時間 1,503 ms
コンパイル使用メモリ 166,828 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 01:03:49
合計ジャッジ時間 3,203 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

i64 power(i64 x, i64 n, i64 mod) {
  i64 ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= mod;
    (x *= x) %= mod;
    n >>= 1;
  }
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  cin >> s;

  int p = 0;
  i64 a, b, c;
  {
    string t;
    for(; s[p] != '^'; ++p) t += s[p];
    a = stoll(t);
    p++;
    a %= mod;
  }
  {
    string t;
    for(; s[p] != '^'; ++p) t += s[p];
    b = stoll(t);
    p++;
  }
  {
    string t;
    for(; p < s.size(); ++p) t += s[p];
    c = stoll(t);
  }

  {
    i64 ret = power(a, b, mod);
    i64 res = power(ret, c, mod);
    cout << res << " ";
  }
  {
    i64 ret = power(b, c, mod - 1);
    i64 res = power(a, ret, mod);
    cout << res << endl;
  }
}
0