結果
| 問題 |
No.147 試験監督(2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-27 11:22:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 976 bytes |
| コンパイル時間 | 699 ms |
| コンパイル使用メモリ | 73,144 KB |
| 実行使用メモリ | 201,064 KB |
| 最終ジャッジ日時 | 2024-09-24 11:24:03 |
| 合計ジャッジ時間 | 7,598 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 2 MLE * 1 |
ソースコード
#include <iostream>
#include <vector>
#include <unordered_map>
#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;
int fib(ll n) {
static unordered_map<ll,int> memo;
if (memo.count(n)) return memo[n];
if (n == 0 or n== 1) return memo[n] = 1;
ll a = n/2, b = (n+1)/2;
return memo[n] = (fib(a)*(ll)fib(b) + fib(a-1)*(ll)fib(b-1)) % mod;
}
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;
}