結果

問題 No.444 旨味の相乗効果
ユーザー square1001square1001
提出日時 2018-05-19 21:19:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,500 ms
コード長 1,070 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 65,556 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 23:48:59
合計ジャッジ時間 2,300 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 41 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 22 ms
4,380 KB
testcase_13 AC 12 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 41 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 33 ms
4,380 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
const int mod = 1000000007;
int n, a[85], x[85][85], y[85][85], z[85][85]; long long b;
int main() {
	cin >> n >> b; b--;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		x[i][i] = a[i];
		for (int j = 0; j <= i; j++) y[j][i] = a[i];
	}
	while (b) {
		if (b & 1) {
			for (int i = 0; i < n; i++) {
				for (int j = i; j < n; j++) {
					z[i][j] = 0;
					for (int k = i; k <= j; k++) {
						z[i][j] = (z[i][j] + 1LL * x[i][k] * y[k][j]) % mod;
					}
				}
			}
			for (int i = 0; i < n; i++) {
				for (int j = i; j < n; j++) {
					x[i][j] = z[i][j];
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j < n; j++) {
				z[i][j] = 0;
				for (int k = i; k <= j; k++) {
					z[i][j] = (z[i][j] + 1LL * y[i][k] * y[k][j]) % mod;
				}
			}
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j < n; j++) {
				y[i][j] = 1LL * z[i][j];
			}
		}
		b >>= 1;
	}
	int ret = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ret = (ret + x[i][j]) % mod;
		}
	}
	cout << ret << '\n';
	return 0;
}
0