QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#592579#6810. Array ConcatenationDixiky_215WA 2ms8632kbC++17924b2024-09-27 00:02:572024-09-27 00:02:58

Judging History

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

  • [2024-09-27 00:02:58]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8632kb
  • [2024-09-27 00:02:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAXN=1e6+7;
const int ep=100;
const double eps=1e-9;
const ll mod=1e9+7LL;
int n,m;
ll a[MAXN],b[MAXN];

int main()
{
	ios::sync_with_stdio(false);
    cout.tie(0);cin.tie(0);
	
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i],b[i]=a[i];	
	ll sum=0,ans1=0LL,len=2*n;
	for(int i=n+1;i<=2*n;i++) a[i]=a[i-n];
	for(int i=1;i<=2*n;i++)
	{
		sum+=a[i];
		ans1+=a[i]*(n*2LL-i+1LL);
	}
	for(int i=2;i<=m;i++)
	{
		ans1+=ans1+sum*len;
		ans1%=mod;
		len*=2LL;sum*=2LL;
		len%=mod;sum%=mod;
	}

	sum=0;len=2*n;
	ll ans2=0LL;
	for(int i=1;i<=n;i++) a[i]=b[n+1-i];
	for(int i=1;i<=2*n;i++)
	{
		sum+=a[i];
		ans2+=a[i]*(n*2LL-i+1LL);
	}
	for(int i=2;i<=m;i++)
	{
		ans2+=ans2+sum*len;
		ans2%=mod;
		len*=2LL;sum*=2LL;
		len%=mod;sum%=mod;
	}
	cout<<max(ans1,ans2);
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5780kb

input:

2 1
1 2

output:

15

result:

ok single line: '15'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5660kb

input:

5 10
26463 39326 86411 75307 85926

output:

806275469

result:

ok single line: '806275469'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5716kb

input:

3 10000
329770536 859936159 696111818

output:

325223749

result:

ok single line: '325223749'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5656kb

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: 2ms
memory: 8632kb

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:

392719309

result:

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