QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226641 | #6810. Array Concatenation | 326173163qqom# | WA | 18ms | 3832kb | C++20 | 676b | 2023-10-26 12:05:58 | 2023-10-26 12:05:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,mod=1e9+7;
int n,m,a[N];
ll lp=0,sum=0;
ll ksm(ll di,ll mi) {ll res=1; for(;mi;mi>>=1,di=di*di%mod) if(mi&1) res=res*di%mod; return res;}
int main() {
int i,j;
scanf("%d%d",&n,&m);
for(i=1;i<=n;i++) scanf("%d",&a[i]);
for(i=1;i<=n;i++)
(lp+=1ll*(2*(n-i+1)-n+mod)*a[i])%mod,
(sum+=a[i])%=mod;
ll res=max((n*ksm(2,2*m-1)%mod*sum+ksm(2,m-1)*lp)%mod,(n*ksm(2,2*m-1)+ksm(2,m-1))%mod*sum%mod);
for(i=0;i<m-1;i++) j=m-i-2,res=max(res,(n*ksm(2,2*i+2)%mod*ksm(2,2*j+1)%mod*sum%mod+ksm(2,i+j+1)*sum)%mod);
cout<<res<<'\n';
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
input:
2 1 1 2
output:
15
result:
ok single line: '15'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
5 10 26463 39326 86411 75307 85926
output:
806275469
result:
ok single line: '806275469'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3688kb
input:
3 10000 329770536 859936159 696111818
output:
325223749
result:
ok single line: '325223749'
Test #4:
score: -100
Wrong Answer
time: 18ms
memory: 3820kb
input:
10 100000 910385778 832405357 79882277 740539785 58009121 361679935 208356273 191444931 327043571 40502864
output:
407766206
result:
wrong answer 1st lines differ - expected: '551220212', found: '407766206'