結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
h_noson
|
| 提出日時 | 2016-04-19 11:36:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,530 bytes |
| コンパイル時間 | 710 ms |
| コンパイル使用メモリ | 73,424 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-04 14:03:52 |
| 合計ジャッジ時間 | 4,545 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000
#define MOD 1000000007
typedef long long ll;
vector<vector<ll>> ini(2,vector<ll>(2));
vector<vector<ll>> mult(vector<vector<ll>> a, vector<vector<ll>> b) {
int i, j, k;
vector<vector<ll>> c(2,vector<ll>(2));
rep (i,2) rep (j,2) rep (k,2) {
c[i][j] += a[i][k] * b[k][j];
c[i][j] %= MOD;
}
return c;
}
ll solve(ll c) {
int i, j;
vector<vector<ll>> mat(2,vector<ll>(2));
auto x = ini;
mat[0][0] = mat[1][1] = 1;
mat[0][1] = mat[1][0] = 0;
while (c > 0) {
if (c % 2)
mat = mult(x,mat);
x = mult(x,x);
c /= 2;
}
return mat[1][0] * 2 + mat[1][1];
}
ll power(ll x, ll n) {
ll ret = 1;
while (n > 0) {
if (n % 2) {
ret *= x;
ret %= MOD;
}
x *= x;
x %= MOD;
n /= 2;
}
return ret;
}
int main() {
int i, n;
ll ans;
cin >> n;
ans = 1;
ini[0][0] = ini[0][1] = ini[1][0] = 1;
ini[1][1] = 0;
rep (i,n) {
ll c, d;
string sd;
cin >> c >> sd;
d = 0;
for (auto chr : sd)
d = (d * 10 + chr - '0') % (MOD-1);
ans *= power(solve(c),d) % MOD;
ans %= MOD;
}
cout << ans << endl;
return 0;
}
h_noson