結果

問題 No.147 試験監督(2)
ユーザー onakaT_TitaionakaT_Titai
提出日時 2019-12-10 20:20:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,543 bytes
コンパイル時間 9,939 ms
コンパイル使用メモリ 361,552 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-06 07:30:12
合計ジャッジ時間 17,905 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

typedef vector<int> vec;
typedef vector<vec> mat;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long mod_pow_boost(long long x, cpp_int n) {
    long long res = 1;
    for (; n > 0; n >>= 1) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}


mat mul(mat &A, mat&B) {
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++) {
        for (int k = 0; k < B.size(); k++) {
            for (int j = 0; j < B[0].size(); j++) {
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % MOD;
            }
        }
    }
    return C;
}

mat pow(mat A, long long n) {
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++) {
        B[i][i] = 1;
    }
    while (n > 0) {
        if (n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

long long calc_rem(string x) {
    long long ret = 0;
    for (int i = 0; i < x.length(); i++) {
        ret *= 10;
        ret += x[i] - '0';
        ret %= MOD;
    }
    return ret%MOD;
}

int main(void) {
    int N; cin >> N;
    long long ans = 1;
    mat A(2, vec(2));
    A[0][0] = 1; A[0][1] = 1;
    A[1][0] = 1; A[1][1] = 0;
    for (int i = 0; i < N; i++) {
        long long C; cin >> C;
        cpp_int D; cin >> D;
        mat AP = pow(A, C);
        long long x = (AP[1][0] * 2 % MOD + AP[1][1]) % MOD;
        x = mod_pow_boost(x, D);
        ans = ans * x % MOD;
    }
    cout << ans << endl;
}
0