QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#404193 | #6810. Array Concatenation | jiajieshi | WA | 1ms | 3600kb | C++20 | 1.5kb | 2024-05-03 15:45:46 | 2024-05-03 15:45:46 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std ;
#define int long long
#define cer2(a,b) cerr<<#a<<'='<<(a)<<','<<#b<<'='<<(b)<<"@ line"<<__LINE__<<endl
#define cer(a) cerr<<#a<<'='<<(a)<<"@ line"<<__LINE__<<endl
const int N = 2e5+3, mod=1e9+7;
int a[N] ,n ,m ,s1[N] ,s2[N];
int b1[N],b2[N],tot;
signed main(){
#ifndef ONLINE_JUDGE
freopen("C:\\Users\\JIAJIEASHI\\Desktop\\in.cpp","r",stdin);
// freopen("out.cpp","w",stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n>>m ;
int m1=0, m2=0;
for(int i=1;i<=n;i++) cin>>a[i] ,s1[i]=s1[i-1]+a[i];
for(int i=n;i>0;i--) s2[i] =s2[i+1] +a[i];
// cer2(m1,m2);
int t =0 ,S=0 ;
for(int i=1;i<=n;i++) b1[++tot] = a[i] ;
for(int i=1;i<=n;i++) b1[++tot] =a[i] ;
// cer(tot);
for(int i=1;i<=tot;i++) b1[i]+=b1[i-1], m1+=b1[i] ;
tot=0;
int SL;
for(int i=n;i>0;i--) b2[++tot] =a[i] ;
for(int i=1;i<=n;i++) b2[++tot] =a[i] ;
for(int i=1;i<=tot;i++) b2[i]+=b2[i-1],m2+=b2[i] ;
// cer2(m1,m2);
if(m1>=m2)// ·ÅÔÚÇ°Ãæ
{
S=m1;
SL=b1[n]*2;
}else{//·ÅÔÚºóÃæ
S=m2;
SL=b2[n]*2;
}
// for(int i=1;i<=tot;i++) cout << b[i] <<' '; cout<<endl;
// for(int i=1;i<=tot;i++)
// tmp+=b[i],tmp%=mod ;
// cout <<tmp <<endl;
// for(int i=1;i<=tot;i++) cout <<b[i] <<' '; cout<<endl;
// cout <<S%=mod;
// cer(S);
int L = 2*n ;
for(int i=1;i<=m-1;i++,L*=2){
// S*=(L+2),S%=mod ;
S=2*S+L*SL;
S%=mod;
SL*=2;
SL%=mod;
}
cout <<S <<endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3536kb
input:
2 1 1 2
output:
15
result:
ok single line: '15'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
5 10 26463 39326 86411 75307 85926
output:
806275469
result:
ok single line: '806275469'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3600kb
input:
3 10000 329770536 859936159 696111818
output:
533504158
result:
wrong answer 1st lines differ - expected: '325223749', found: '533504158'