結果
| 問題 |
No.444 旨味の相乗効果
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-01-01 18:46:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 924 bytes |
| コンパイル時間 | 402 ms |
| コンパイル使用メモリ | 31,360 KB |
| 実行使用メモリ | 13,772 KB |
| 最終ジャッジ日時 | 2025-01-01 18:46:39 |
| 合計ジャッジ時間 | 24,554 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 TLE * 1 |
| other | AC * 3 WA * 14 TLE * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:15: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | int c; scanf("%d %d",&n,&c);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:22:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | for(int i=1;i<=n;i++) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<cstdio>
using namespace std;
const int N=90,Mod=1e9+7; int n,a[N];
struct Matrix { long long a[N][N]; }ans,p;
Matrix operator *(Matrix a,Matrix b) {
Matrix c;
for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) for(int k=1;k<=n;k++) (c.a[i][j]+=a.a[i][k]*b.a[k][j]%Mod)%=Mod;
return c;
}
long long qpow(long long a,long long b) {
long long ans=1;
while(b) {
if(b&1) ans=ans*a%Mod;
a=a*a%Mod,b>>=1;
}
return ans;
}
int main() {
//freopen("spice.in","r",stdin);
//freopen("spice.out","w",stdout);
int c; scanf("%d %d",&n,&c);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++) ans.a[i][i]=1;
for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) p.a[i][j]=a[j];
int t=c;
while(c) {
if(c&1) ans=ans*p;
p=p*p,c>>=1;
}
long long sum=0;
for(int i=1;i<=n;i++) (sum+=ans.a[1][i])%=Mod;
for(int i=1;i<=n;i++) (sum-=qpow(a[i],t))%=Mod;
printf("%lld",(sum+Mod)%Mod);
return 0;
}
vjudge1