QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#679752 | #6810. Array Concatenation | lllei# | WA | 0ms | 3600kb | C++20 | 938b | 2024-10-26 18:25:11 | 2024-10-26 18:25:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+20;
const int M=1e9+7;
long long n,m;
long long a[N];
long long ans1,ans2;
long long pw(long long t1,long long t2)
{
long long tmp1=1,tmp2=t1;
while(t2)
{
if(t2&1) tmp1=tmp1*tmp2%M;
tmp2=tmp2*tmp2%M;
t2/=2;
}
return tmp1;
}
__int128 sum1,sum2;
long long sum;
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++) {cin>>a[i];sum=(sum+a[i])%M;}
long long tmp=pw(2,m);
ans1=tmp*((tmp-1+M)%M)*pw(2,M-2)%M*n%M;
ans1=ans1*sum%M;
sum1=0;
for(int i=1;i<=n;i++)
{
sum1=sum1+a[i]*(n-i+1);
}
sum2=0;
for(int i=1;i<=n;i++)
{
sum2=sum2+a[i]*(i);
}
sum1%=M;sum2%=M;
if(sum1>=sum2){
ans2=sum1*pw(2,m)%M;
}
else
{
ans2=(sum1*pw(2,m-1)%M+sum2*pw(2,m-1)%M)%M;
}
cout<<(ans1+ans2)%M;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
2 1 1 2
output:
15
result:
ok single line: '15'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
5 10 26463 39326 86411 75307 85926
output:
806275469
result:
ok single line: '806275469'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3528kb
input:
3 10000 329770536 859936159 696111818
output:
-96087066
result:
wrong answer 1st lines differ - expected: '325223749', found: '-96087066'