結果

問題 No.147 試験監督(2)
ユーザー keikei
提出日時 2018-08-18 14:17:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,839 bytes
コンパイル時間 1,978 ms
コンパイル使用メモリ 173,572 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-23 05:06:33
合計ジャッジ時間 3,219 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://yukicoder.me/problems/no/147>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
void test(){
    for(int i = 1; i <= 10;i++){
        int cnt = 0;
        for(int j = 0; j < (1<<i);j++){
            cnt++;
            for(int k = 0; k < i;k++){
                if(((j>>k)&1)&((j>>(k+1))&1)){
                    cnt--;
                    break;
                }
            }
        }
        cout << i << " " << cnt << endl;
    }
    
}

ll mod(string& S){
    ll ret = 0;
    for(auto& c:S){
        ret = (ret*10 + c - '0')%MOD;
    }
    return ret;
}

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

mat pow(mat A,ll n,const ll M){
    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,M);
        A = mul(A,A,M);
        n>>=1;
    }
    return B;
}
ll powmod(ll a,ll b) {ll res=1;a%=MOD;for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

ll solve(){
    ll res = 1;
    ll N; cin >> N;
    while(N--){
        ll C; string D; cin >> C >> D;
        mat A = {{1,1},{1,0}};
        ll n = (C+2)%MOD;
        auto F = pow(A,n,MOD);
        (res *=  powmod(F[0][1],mod(D)))%=MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    //test();
    cout << solve() << endl;
    return 0;
}
0