QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226630 | #6810. Array Concatenation | 326173163qqom# | WA | 0ms | 3840kb | C++20 | 691b | 2023-10-26 11:29:47 | 2023-10-26 11:29:47 |
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]);
long double la=0,lb=0,lc=n;
for(i=1;i<m;i++) lc/=2;
for(i=1;i<=n;i++) la+=(2*(n-i+1)-n)*(long double)(a[i]),
(lp+=1ll*(2*(n-i+1)-n+mod)*a[i])%mod,
lb+=a[i],(sum+=a[i])%=mod;
if(la>lb)
cout<<(n*ksm(2,2*m-1)%mod*sum+ksm(2,m-1)*lp)%mod;
else
cout<<(n*(ksm(2,2*m-1))+ksm(2,m-1))%mod*sum%mod;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
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: 0ms
memory: 3720kb
input:
3 10000 329770536 859936159 696111818
output:
325223749
result:
ok single line: '325223749'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3632kb
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'