結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-08-21 12:41:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,412 bytes |
| コンパイル時間 | 1,184 ms |
| コンパイル使用メモリ | 159,864 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 11:15:47 |
| 合計ジャッジ時間 | 2,659 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 1 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a) rep2 (i, 0, a)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) repr2 (i, 0, a)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define asn(a, b, c) fill_n(&(b), sizeof(a) / sizeof(b), c)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
void matmul(ll A[2][2], ll B[2][2]) {
ll a[2][2], b[2][2];
rep (i, 2) {
rep (j, 2) {
a[i][j] = A[i][j];
b[i][j] = B[i][j];
B[i][j] = 0;
}
}
rep (i, 2) {
rep (k, 2) {
rep (j, 2) {
(B[i][j] += a[i][k] * b[k][j]) %= mod;
}
}
}
}
void matpow(ll A[2][2], ll b, ll res[2][2]) {
rep (i, 2) rep (j, 2) res[i][j] = i == j;
while (b) {
if (b & 1) matmul(A, res);
matmul(A, A);
b >>= 1;
}
}
ll modpow(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1) (res *= a) %= mod;
(a *= a) %= mod;
b >>= 1;
}
return res;
}
ll bigmodulo(string &s, ll m) {
ll res = 0;
for (char d : s) {
res *= 10;
res += d - '0';
res %= m;
}
return res;
}
ll bigmodpow(ll a, string &b) {
ll B = bigmodulo(b, mod - 1);
return modpow(a, B);
}
int main() {
int N;
cin >> N;
ll ans = 1;
rep (i, N) {
ll C;
string D;
cin >> C >> D;
ll A[2][2] = {{1, 1}, {1, 0}};
ll An[2][2];
matpow(A, C, An);
ll m = (An[0][0] + An[1][0]) % mod;
ans *= bigmodpow(m, D);
ans %= mod;
}
cout << ans << endl;
return 0;
}