結果
| 問題 |
No.444 旨味の相乗効果
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-01-01 18:49:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,003 bytes |
| コンパイル時間 | 400 ms |
| コンパイル使用メモリ | 31,284 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-01 18:49:03 |
| 合計ジャッジ時間 | 2,450 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 4 |
| other | AC * 3 WA * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:21:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | long long c; scanf("%d %lld",&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;
}
int qpow(int a,long long b) {
int ans=1;
while(b) {
if(b&1) ans=1ll*ans*a%Mod;
a=1ll*a*a%Mod,b>>=1;
}
return ans;
}
int main() {
//freopen("spice.in","r",stdin);
//freopen("spice.out","w",stdout);
long long c; scanf("%d %lld",&n,&c);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<=n;i++) for(int j=i;j<=n;j++) ans.a[i][j]=p.a[i][j]=a[j];
long long t=c; c--;
while(c) {
if(c&1) ans=ans*p;
p=p*p,c>>=1;
}
//for(int i=1;i<=n;i++) {
//for(int j=1;j<=n;j++) printf("%lld ",ans.a[i][j]);
//puts("");
//}
int 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("%d",(sum+Mod)%Mod);
return 0;
}
vjudge1