QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622450#6810. Array ConcatenationSound_MediumWA 7ms4512kbC++231.1kb2024-10-08 21:47:562024-10-08 21:47:59

Judging History

你现在查看的是最新测评结果

  • [2024-10-08 21:47:59]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:4512kb
  • [2024-10-08 21:47:56]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+20;
const int mod=1e9+7;
int n, m;
int a[N];
int qmi(int a,int b){
    int res=1;
    while(b){
        if(b&1)res=res*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return res%mod;
}
void solve () {
    cin>>n>>m;
    int sum1=0,sum2=0,pre1=0,pre2=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pre1+=a[i];
        sum1+=pre1;
        sum1%=mod;
    }
    for(int i=n;i>=1;i--){
        pre2+=a[i];
        sum2+=pre2;
        sum2%=mod;
    }
    // cerr<<sum1<<" "<<sum2<<endl;
    int k1=sum1*qmi(2,m-1)%mod;
    int k2=sum2*qmi(2,m-1)%mod;
    int k3=k1*(2ll)%mod;
    int k4=(qmi(2,m-1))*((pre1*(((qmi(2,m)-1)%mod+mod)%mod)%mod))%mod;
    // cerr<<k4<<endl;
    k4=k4*n%mod;
    int ans1=k1+k2+k4;
    // cerr<<k1<<" "<<k2<<" "<<k3<<" "<<k4<<endl;
    int ans2=k4+k3;
    // cerr<<(ans1%mod)<<" "<<(ans2%mod)<<endl;      
    cout<<max(ans1%mod,ans2%mod);

}
signed main () {
    int T = 1; 
    std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    //cin>>T;
    while (T --) solve ();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3692kb

input:

2 1
1 2

output:

15

result:

ok single line: '15'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

5 10
26463 39326 86411 75307 85926

output:

806275469

result:

ok single line: '806275469'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

3 10000
329770536 859936159 696111818

output:

325223749

result:

ok single line: '325223749'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

10 100000
910385778 832405357 79882277 740539785 58009121 361679935 208356273 191444931 327043571 40502864

output:

551220212

result:

ok single line: '551220212'

Test #5:

score: -100
Wrong Answer
time: 7ms
memory: 4512kb

input:

99998 99999
424541359 970848132 124944765 190568793 218987145 439687684 674898132 26756266 495705287 999481800 123311748 808192729 480063991 282558300 432664601 480692564 771223766 592954167 648647039 80490877 501738111 3075724 426165921 557518328 209501102 786985447 129062653 705971029 763019010 16...

output:

524665325

result:

wrong answer 1st lines differ - expected: '371554090', found: '524665325'