QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739720 | #6810. Array Concatenation | caiwen | WA | 0ms | 1608kb | C++14 | 745b | 2024-11-12 22:49:17 | 2024-11-12 22:49:18 |
Judging History
answer
//Powered by COJ
//fd76fed2-7e6c-496a-8a1d-e383ead62ce5
#include<cstdio>
using namespace std;
const long long M=1e9+7;
int main()
{
long long n,m,x=0,y=0,g=0;
scanf("%Ld%Ld",&n,&m);
for(long long i=1;i<=n;i++)
{
long long a;
scanf("%Ld",&a);
x+=a*i;
y+=a*(n-i+1);
g+=a;
x%=M;
y%=M;
g%=M;
}
if(y>=x)
{
long long h=0,pw=1;
for(long long i=1;i<=m;i++)
{
pw*=2;
pw%=M;
}
h+=y*pw;
h%=M;
long long p=pw*(pw-1)/2,q=n*g;
p%=M;
q%=M;
h+=p*q;
h%=M;
printf("%Ld",h);
}
else
{
long long h=0,pw=1;
for(long long i=1;i<m;i++)
{
pw*=2;
pw%=M;
}
h+=y*pw+x*pw;
h%=M;
pw*=2;
pw%=M;
long long p=pw*(pw-1)/2,q=n*g;
p%=M;
q%=M;
h+=p*q;
h%=M;
printf("%Ld",h);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1608kb
input:
2 1 1 2
output:
15
result:
ok single line: '15'
Test #2:
score: 0
Accepted
time: 0ms
memory: 1600kb
input:
5 10 26463 39326 86411 75307 85926
output:
806275469
result:
ok single line: '806275469'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 1596kb
input:
3 10000 329770536 859936159 696111818
output:
9530648
result:
wrong answer 1st lines differ - expected: '325223749', found: '9530648'