結果

問題 No.147 試験監督(2)
コンテスト
ユーザー T1610
提出日時 2026-09-20 21:40:40
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 2,516 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,943 ms
コンパイル使用メモリ 378,736 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2026-09-20 21:40:54
合計ジャッジ時間 6,358 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for (ll i = (s); i < (ll)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for (ll i = (ll)(s - 1); i >= (ll)(e); i--)
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T, typename U>
T chmax(T& a, const U& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <typename T, typename U>
T chmin(T& a, const U& b) {
    if (a <= b) return false;
    a = b;
    return true;
}

void yes_no(bool f, string yes = "Yes", string no = "No") { cout << (f ? yes : no) << "\n"; }

template <class T, int SZ>
struct Mat {
    array<array<T, SZ>, SZ> d;
    const int n;
    Mat() : n(SZ) {
        array<T, SZ> tmp;
        d.fill(tmp);
    }
    Mat(const array<array<T, SZ>, SZ>& d) : n(SZ), d(d) {}
    Mat operator*(const Mat& mt) const {
        Mat ret;
        rep(i, SZ) rep(j, SZ) {
            rep(k, SZ) {
                ret.d[i][j] += (d[i][k] * mt.d[k][j]);
            }
        }
        return ret;
    }
    Mat& operator*=(const Mat& mt) {
        *this = *this * mt;
        return *this;
    }
    Mat& operator=(const Mat& mt) {
        d = mt.d;
        return *this;
    }
    Mat(Mat&&) = default;
    array<T, SZ>& operator[](const int n) {
        return d[n];
    }
    Mat pow(ll n) const {
        Mat tmp(this->d);
        Mat<T, SZ> ret;
        rep(i, SZ) ret.d[i][i] = 1LL;
        while (n > 0) {
            if (n & 1LL) ret = ret * tmp;
            tmp *= tmp;
            n >>= 1;
        }
        return ret;
    }
};

void solve() {
    int n;
    cin >> n;
    using mint = modint1000000007;
    mint ans = 1;
    rep(ni, n) {
        ll c;
        cin >> c;
        Mat<mint, 2> x;
        x.d[0][0] = 1;
        x.d[0][1] = 1;
        x.d[1][0] = 1;
        x.d[1][1] = 0;
        auto y = x.pow(c - 1);
        mint z = 0;
        rep(i, 2) rep(j, 2) z += y.d[i][j];
        using mint2 = static_modint<(int)1e9 + 6>;
        mint2 d = 0;
        string s;
        cin >> s;
        rep(i, s.size()) {
            d *= 10;
            d += (s[i] - '0');
        }
        ans *= z.pow(d.val());
    }
    cout << ans.val() << "\n";
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t = 1;
    // multi-testcase
    // cin >> t;
    rep(ti, t) solve();
    return 0;
}
0