結果
| 問題 |
No.444 旨味の相乗効果
|
| コンテスト | |
| ユーザー |
rickytheta
|
| 提出日時 | 2016-11-11 23:38:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 175 ms / 2,500 ms |
| コード長 | 1,583 bytes |
| コンパイル時間 | 2,090 ms |
| コンパイル使用メモリ | 165,232 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-24 20:51:25 |
| 合計ジャッジ時間 | 3,048 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:58:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
58 | scanf("%lld%lld",&n,&c);
| ~~~~~^~~~~~~~~~~~~~~~~~
main.cpp:59:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
59 | REP(i,n)scanf("%lld",a+i);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;
ll n,c;
ll a[85];
typedef vector<vl> mat;
mat mul(mat &a,mat &b){
int n = a.size();
mat ret(n,vl(n,0));
REP(k,n)REP(i,n)REP(j,n)ret[i][j] = (ret[i][j] + a[i][k]*b[k][j]%MOD)%MOD;
return ret;
}
ll mypow(ll a,ll b){
b %= (MOD-1);
ll r = 1;
while(b){
if(b&1)r=r*a%MOD;
a=a*a%MOD;
b>>=1;
}
return r;
}
int main(){
scanf("%lld%lld",&n,&c);
REP(i,n)scanf("%lld",a+i);
mat A(n,vl(n,0));
REP(i,n)REP(j,i+1)A[i][j] = a[i];
mat I(n,vl(n,0));
REP(i,n)I[i][i]=1;
mat B = I;
ll k = c;
--c;
while(c){
if(c&1) B=mul(A,B);
A=mul(A,A);
c>>=1;
}
ll sum = 0;
REP(i,n)REP(j,n)sum = (sum + B[i][j]*a[j]%MOD)%MOD;
REP(i,n)sum = (sum-mypow(a[i],k)+MOD)%MOD;
printf("%lld\n",sum);
return 0;
}
rickytheta