QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#404225 | #6810. Array Concatenation | jiajieshi | WA | 9ms | 14536kb | C++20 | 1.9kb | 2024-05-03 16:22:58 | 2024-05-03 16:23:28 |
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
#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];
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];
// 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: 3568kb
input:
2 1 1 2
output:
15
result:
ok single line: '15'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
5 10 26463 39326 86411 75307 85926
output:
806275469
result:
ok single line: '806275469'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
3 10000 329770536 859936159 696111818
output:
325223749
result:
ok single line: '325223749'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3788kb
input:
10 100000 910385778 832405357 79882277 740539785 58009121 361679935 208356273 191444931 327043571 40502864
output:
551220212
result:
ok single line: '551220212'
Test #5:
score: 0
Accepted
time: 8ms
memory: 14496kb
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:
371554090
result:
ok single line: '371554090'
Test #6:
score: 0
Accepted
time: 0ms
memory: 6124kb
input:
23854 89381 394875321 358990454 858102462 384724857 275727903 97926601 474697159 911286664 206848005 33299065 794156923 141542667 429367570 397169821 74508725 520716485 677478792 133016266 58719731 925502886 956794304 194692492 985435726 883349224 42102293 676396529 839744928 366681778 656265608 115...
output:
426677952
result:
ok single line: '426677952'
Test #7:
score: 0
Accepted
time: 5ms
memory: 12664kb
input:
83492 48249 70494500 885620970 315369497 739608603 637096477 10395600 246855095 506270453 443170180 577100499 577449412 138165292 246928155 689186056 498722336 790825887 594302101 414730621 572006760 546794452 98888789 727318449 857676435 114468371 676126291 935100863 178502984 187768465 696814401 6...
output:
510020598
result:
ok single line: '510020598'
Test #8:
score: 0
Accepted
time: 9ms
memory: 14536kb
input:
99824 43532 774340602 936278614 964709803 488385916 459911693 6573867 299867606 777690440 87564223 407397293 234189335 321895358 125495230 145168763 182375587 226125349 301825885 840410768 846358234 257084607 187826907 26856116 65896632 752477170 556078517 496528163 816563279 928793952 38603811 8858...
output:
263266590
result:
ok single line: '263266590'
Test #9:
score: -100
Wrong Answer
time: 7ms
memory: 14532kb
input:
100000 40 735211086 438848581 883369263 411520254 96701572 639546923 41849752 603158600 721918949 2491206 846495417 323507652 718479900 610177876 169869700 545169629 512881910 798460780 380319407 851809813 556619434 326106153 766145881 413339664 941433832 816866760 79378460 799224104 568687839 84804...
output:
33458924
result:
wrong answer 1st lines differ - expected: '306284744', found: '33458924'