結果

問題 No.444 旨味の相乗効果
ユーザー cielciel
提出日時 2016-11-15 18:37:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,500 ms
コード長 563 bytes
コンパイル時間 438 ms
コンパイル使用メモリ 59,212 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 02:18:14
合計ジャッジ時間 1,891 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 77 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 40 ms
4,376 KB
testcase_13 AC 30 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 77 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 11 ms
4,380 KB
testcase_20 AC 72 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:12:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   12 | main(){
      | ^~~~

ソースコード

diff #

#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<__int128_t>V;
int n,m=1000000007;
V z;
V &Me(const V &_x,const V &_y){
	int i=0,j;
	for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	return z;
}
main(){
	long long R=0,r;
	int y,i=0,j;
	scanf("%d%lld",&n,&r);
	V x(n*n);
	V e(n*n);
	z.resize(n*n);
	for(;i<n;i++){
		scanf("%d",&y);
		e[i*n+i]=1;
		for(j=0;j<=i;j++)x[i*n+j]=y;
	}
	for(;r;r>>=1){
		if(r&1)e=Me(e,x);
		x=Me(x,x);
	}
	for(i=0;i<n;i++)R+=m+e[i*n]-e[i*n+i];
	printf("%lld\n",(R%m+m)%m);
}
0