結果
| 問題 | No.865 24時間降水量 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-27 21:14:01 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,586 bytes |
| 記録 | |
| コンパイル時間 | 338 ms |
| コンパイル使用メモリ | 75,104 KB |
| 実行使用メモリ | 9,804 KB |
| 最終ジャッジ日時 | 2026-08-27 21:14:20 |
| 合計ジャッジ時間 | 8,697 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 15 TLE * 3 |
ソースコード
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
const int N = 10, MOD = 17;
int q;
struct Matrix {
int v[N][N];
static Matrix Identity() {
Matrix identity = {};
for (int i = 1; i < N; ++i) identity.v[i][i] = 1;
return identity;
}
Matrix operator *(Matrix o) {
Matrix ret = {};
for (int i = 1; i < N; ++i) {
for (int j = 1; j < N; ++j) {
for (int k = 1; k < N; ++k) {
ret.v[i][k] = (ret.v[i][k] + 1LL * v[i][j] * o.v[j][k]) % MOD;
}
}
}
return ret;
}
Matrix operator *=(Matrix o) {
*this = *this * o;
return *this;
}
};
Matrix QMI(Matrix a, LL k) {
Matrix ret = Matrix::Identity();
while (k) {
if (k & 1) ret *= a;
a *= a;
k >>= 1;
}
return ret;
}
int main() {
// freopen("fib.in", "r", stdin);
// freopen("fib.out", "w", stdout);
scanf("%d", &q);
while (q--) {
LL n;
scanf("%lld", &n);
Matrix a = {};
a.v[1][1] = a.v[1][2] = a.v[1][3] = 0;
a.v[1][4] = 1;
Matrix b = {};
b.v[1][1] = b.v[1][2] = b.v[1][3] = b.v[2][2] = b.v[2][3] = b.v[3][1] = b.v[3][3] = b.v[4][1] = b.v[4][2] = 0;
b.v[1][4] = b.v[2][1] = b.v[2][4] = b.v[3][2] = b.v[3][4] = b.v[4][3] = b.v[4][4] = 1;
if (n < 4) {
printf("%d\n", a.v[1][n]);
} else {
a *= QMI(b, n - 4);
printf("%d\n", a.v[1][4]);
}
}
return 0;
}