QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#404223#6810. Array ConcatenationjiajieshiWA 1ms3708kbC++202.0kb2024-05-03 16:22:112024-05-03 16:22:11

Judging History

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

  • [2024-05-03 16:22:11]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-05-03 16:22:11]
  • 提交

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
#define ull unsigned long long
#define ll long long
const int N = 2e5+100, mod=1e9+7;
__int128 a[N] ,n ,m ,s1[N] ,s2[N];
__int128 b1[N],b2[N],tot;
void scan(__int128 &x){//input
	x = 0;
	int f = 1;
	char ch;
	if((ch = getchar()) == '-'){
		f = -1;
	}else{
		x = x * 10 + (ch - '0');
	}
	while((ch = getchar()) >= '0' && ch <= '9'){
		x = x * 10 + (ch - '0');
	}
	x *= f;
} 
void print(__int128 x){//output 
	if(x < 0){
		x = -x;
		putchar('-');
	}
	if(x > 9){
		print(x/10);//recursion
	}
	putchar(x%10+'0');
}
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);
 	scan(n);
 	scan(m);
 	__int128 m1=0, m2=0; 
 	for(int i=1;i<=n;i++) scan(a[i]) ,s1[i]=s1[i-1]+a[i],s1[i]%=mod;
 	for(int i=n;i>0;i--) s2[i] =s2[i+1] +a[i],s2[i]%=mod;
// 	cer2(m1,m2);
 	__int128 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],m1%=mod;
	    
	    tot=0;
	    __int128 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],m2%=mod;
//		cer2(m1,m2);
	    if(m1>=m2)//  ·ÅÔÚÇ°Ãæ 
	    {
	    	for(int i=1;i<=tot;i++)
	    	{
	    		S+=b1[i];
	    		S%=mod;
			}
	    	SL=b1[n]*2%mod;
		}else{//·ÅÔÚºóÃæ 
			for(int i=1;i<=tot;i++)
			{
				S+=b2[i]%mod;
			}
			SL=b2[n]*2%mod;
		};
//    cer(S);
	__int128 L = 2*n%mod ;
 	for(int i=1;i<=m-1;i++,L*=2){
        L%=mod;
 		S=2*S%mod+L*SL%mod;
 		S%=mod;
 		SL*=2;
 		SL%=mod;
	 }
	 S%=mod;
	 print(S);
 }

详细

Test #1:

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

input:

2 1
1 2

output:

15

result:

ok single line: '15'

Test #2:

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

input:

5 10
26463 39326 86411 75307 85926

output:

806275469

result:

ok single line: '806275469'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3560kb

input:

3 10000
329770536 859936159 696111818

output:

9530648

result:

wrong answer 1st lines differ - expected: '325223749', found: '9530648'