結果

問題 No.147 試験監督(2)
ユーザー kimiyukikimiyuki
提出日時 2016-02-27 11:32:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 786 ms / 2,000 ms
コード長 1,355 bytes
コンパイル時間 924 ms
コンパイル使用メモリ 66,368 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 18:26:03
合計ジャッジ時間 4,456 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 786 ms
4,348 KB
testcase_01 AC 776 ms
4,348 KB
testcase_02 AC 779 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
typedef long long ll;
using namespace std;
const int mod = 1e9+7;
vector<vector<ll> > operator * (vector<vector<ll> > const & p, vector<vector<ll> > const & q) {
    int n = p.size();
    vector<vector<ll> > r(n, vector<ll>(n));
    repeat (y,n) {
        repeat (z,n) {
            repeat (x,n) {
                r[y][x] += p[y][z] * q[z][x] % mod;
                r[y][x] %= mod;
            }
        }
    }
    return r;
}
ll fib(ll n) {
    vector<vector<ll> > f(2, vector<ll>(2));
    vector<vector<ll> > e(2, vector<ll>(2));
    f[0][0] = f[1][1] = 1;
    e[0][0] = e[0][1] = e[1][0] = 1;
    for (ll i = 1; i <= n; i <<= 1) {
        if (n & i) f = f * e;
        e = e * e;
    }
    return f[0][0];
}
int powi(int x, string const & d) {
    ll y = 1;
    int n = d.size();
    repeat_reverse (i,n) {
        int c = d[i] - '0';
        ll z = 1;
        repeat (j,10) {
            if (j == c) y = y * z % mod;
            z = z * x % mod;
        }
        x = z;
    }
    return y;
}
int main() {
    int n; cin >> n;
    ll ans = 1;
    repeat (i,n) {
        ll c; string d; cin >> c >> d;
        ans = ans * powi(fib(c+1), d) % mod;
    }
    cout << ans << endl;
    return 0;
}
0