結果
問題 | No.444 旨味の相乗効果 |
ユーザー | ciel |
提出日時 | 2016-11-15 18:37:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 90 ms / 2,500 ms |
コード長 | 692 bytes |
コンパイル時間 | 811 ms |
コンパイル使用メモリ | 60,408 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 20:58:56 |
合計ジャッジ時間 | 1,729 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 23 |
コンパイルメッセージ
main.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 17 | main(){ | ^~~~
ソースコード
#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; } V &Mx(const V &_x){ int i=0,j; for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_x[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=Mx(x); } for(i=0;i<n;i++)R+=m+e[i*n]-e[i*n+i]; printf("%lld\n",(R%m+m)%m); }