結果

問題 No.2007 Arbitrary Mod (Easy)
ユーザー fact493fact493
提出日時 2022-07-15 21:30:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 3,782 bytes
コンパイル時間 3,817 ms
コンパイル使用メモリ 230,624 KB
実行使用メモリ 15,376 KB
最終ジャッジ日時 2023-09-10 00:38:30
合計ジャッジ時間 9,101 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
15,168 KB
testcase_01 AC 17 ms
15,164 KB
testcase_02 AC 17 ms
15,136 KB
testcase_03 AC 17 ms
15,192 KB
testcase_04 AC 18 ms
15,184 KB
testcase_05 AC 18 ms
15,084 KB
testcase_06 AC 17 ms
15,320 KB
testcase_07 AC 17 ms
15,200 KB
testcase_08 AC 17 ms
15,204 KB
testcase_09 AC 17 ms
15,080 KB
testcase_10 AC 18 ms
15,184 KB
testcase_11 AC 18 ms
15,072 KB
testcase_12 AC 17 ms
15,376 KB
testcase_13 AC 17 ms
15,136 KB
testcase_14 AC 17 ms
15,280 KB
testcase_15 AC 17 ms
15,196 KB
testcase_16 AC 16 ms
15,116 KB
testcase_17 AC 17 ms
15,188 KB
testcase_18 AC 17 ms
15,140 KB
testcase_19 AC 17 ms
15,080 KB
testcase_20 AC 17 ms
15,084 KB
testcase_21 AC 17 ms
15,192 KB
testcase_22 AC 17 ms
15,376 KB
testcase_23 AC 18 ms
15,136 KB
testcase_24 AC 16 ms
15,188 KB
testcase_25 AC 17 ms
15,372 KB
testcase_26 AC 17 ms
15,132 KB
testcase_27 AC 17 ms
15,140 KB
testcase_28 AC 17 ms
15,144 KB
testcase_29 AC 17 ms
15,184 KB
testcase_30 AC 17 ms
15,132 KB
testcase_31 AC 18 ms
15,116 KB
testcase_32 AC 17 ms
15,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> PP;
typedef tuple<ll, ll, ll, ll> PPP;
using vvvvl = vector<vvvl>;
using vp = vector<P>;
using vvp = vector<vp>;
using vb = vector<bool>;
using vvb = vector<vb>;
#define lb(v, k) (lower_bound(all(v), (k)) - v.begin())
#define ub(v, k) (upper_bound(all(v), (k)) - v.begin())
#define fi first
#define se second
#define pq(T) priority_queue<T>
#define pqr(T) priority_queue<T, vector<T>, greater<T>>
#define int long long
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(a) (a).begin(), (a).end()
#define cinvec(x)                     \
    for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \
    {                                 \
        cin >> x.at(hfuaig);               \
    }
#define coutvece(x)                   \
    for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \
    {                                 \
        cout << x.at(hfuaig) << endl;      \
    }
#define coutvec(x)                    \
    for (ll hfuaig = 0; hfuaig < x.size(); hfuaig++) \
    {                                 \
        cout << x.at(hfuaig) << ' ';       \
    }
const ll mod = 998244353;
const ll Mod = 1000000007;
const ll inf = 999999999999999999LL;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
ll gcd(ll A, ll B){
    if(A % B == 0){
        return B;
    }
    else{
        return gcd(B, A % B);
    }
}
long long modpow(long long a, long long n, long long mo) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mo;
        a = a * a % mo;
        n >>= 1;
    }
    return res;
}
#define double long double
bool isd(double a, double b, double c){
    if(c > (a + b) * (a + b)){
        return false;
    }
    if(c == (a + b) * (a + b)){
        return true;
    }
    if(abs(a - b) * abs(a - b) < c && c < (a + b) * (a + b)){
        return true;
    }
    if(c == abs(a - b) * abs(a - b)){
        return true;
    }
    if(c < abs(a - b) * abs(a - b)){
        return false;
    }
    return true;
}

// 考える整数の最大値
const int MAX = 500000;
// 今回採用する大きい素数
const int MOD = 1000000007;

// メモを保管する場所
ll fact[MAX], inv_fact[MAX], inv[MAX];

// メモを計算する
void init() {
    // 初期値設定と1はじまりインデックスに直す
    fact[0] = 1;
    fact[1] = 1;
    inv[0] = 1;
    inv[1] = 1;
    inv_fact[0] = 1;
    inv_fact[1] = 1;
    // メモの計算
    repi(i, 2, MAX){
        // 階乗
        fact[i] = fact[i - 1] * i % MOD;
        // 逆元
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        // 逆元の階乗
        inv_fact[i] = inv_fact[i - 1] * inv[i] % MOD;
    }
}

// 二項係数の実体
ll nck(int n, int k) {
    ll x = fact[n]; // n!の計算
    ll y = inv_fact[n-k]; // (n-k)!の計算
    ll z = inv_fact[k]; // k!の計算
    if (n < k) return 0; // 例外処理
    if (n < 0 || k < 0) return 0; // 例外処理
    return x * ((y * z) % MOD) % MOD; //二項係数の計算
}
void beg(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(20);
    init();
}
//#define _GLIBCXX_DEBUG
short sum100(vector<short> a) {
    short result = 0;
    for (short i = 0; i < 100; i++) {
        result += a.at(i);
    }
    return result;
}
signed main()
{
    beg();
    ll A, N;
    cin >> A >> N;
    cout << mod << endl;
    cout << modpow(A, N, mod) << endl;
}

0