結果
| 問題 | No.147 試験監督(2) |
| コンテスト | |
| ユーザー |
T1610
|
| 提出日時 | 2026-09-20 21:54:48 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 86 ms / 2,000 ms |
| + 917µs | |
| コード長 | 2,610 bytes |
| 記録 | |
| コンパイル時間 | 3,820 ms |
| コンパイル使用メモリ | 378,812 KB |
| 実行使用メモリ | 7,980 KB |
| 最終ジャッジ日時 | 2026-09-20 21:55:05 |
| 合計ジャッジ時間 | 6,211 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for (ll i = (s); i < (ll)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for (ll i = (ll)(s - 1); i >= (ll)(e); i--)
#define all(r) r.begin(), r.end()
#define rall(r) r.rbegin(), r.rend()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <typename T, typename U>
T chmax(T& a, const U& b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T, typename U>
T chmin(T& a, const U& b) {
if (a <= b) return false;
a = b;
return true;
}
void yes_no(bool f, string yes = "Yes", string no = "No") { cout << (f ? yes : no) << "\n"; }
template <class T, int SZ>
struct Mat {
array<array<T, SZ>, SZ> d;
const int n;
Mat() : n(SZ) {
array<T, SZ> tmp;
d.fill(tmp);
}
Mat(const array<array<T, SZ>, SZ>& d) : n(SZ), d(d) {}
Mat operator*(const Mat& mt) const {
Mat ret;
rep(i, SZ) rep(j, SZ) {
rep(k, SZ) {
ret.d[i][j] += (d[i][k] * mt.d[k][j]);
}
}
return ret;
}
Mat& operator*=(const Mat& mt) {
*this = *this * mt;
return *this;
}
Mat& operator=(const Mat& mt) {
d = mt.d;
return *this;
}
Mat(Mat&&) = default;
array<T, SZ>& operator[](const int n) {
return d[n];
}
Mat pow(ll n) const {
Mat tmp(this->d);
Mat<T, SZ> ret;
rep(i, SZ) ret.d[i][i] = 1LL;
while (n > 0) {
if (n & 1LL) ret = ret * tmp;
tmp *= tmp;
n >>= 1;
}
return ret;
}
};
void solve() {
int n;
cin >> n;
using mint = modint1000000007;
mint ans = 1;
rep(ni, n) {
ll c;
cin >> c;
Mat<mint, 2> x;
x.d[0][0] = 1;
x.d[0][1] = 1;
x.d[1][0] = 1;
x.d[1][1] = 0;
auto y = x.pow(c - 1);
mint z = 0;
rep(i, 2) rep(j, 2) z += y.d[i][j];
using mint2 = static_modint<(int)1e9 + 6>;
mint2 d = 0;
string s;
cin >> s;
rep(i, s.size()) {
d *= 10;
d += (s[i] - '0');
}
if (z.val() == 0) {
if (s != "0") ans = 0;
} else {
ans *= z.pow(d.val());
}
}
cout << ans.val() << "\n";
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int t = 1;
// multi-testcase
// cin >> t;
rep(ti, t) solve();
return 0;
}
T1610