-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDCE301.cpp
More file actions
42 lines (42 loc) · 1.6 KB
/
DCE301.cpp
File metadata and controls
42 lines (42 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<stdio.h>
long long int m=1000000007;
int cntr=1;
long long int ans;
int main(){
int t;
scanf("%d",&t);
for(;t>0;t--){
ans=0;
int n;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
int b[3000]={0};
int pos=n/2+1;
while(pos!=1){
if(b[pos]==1)pos--;if(b[pos]==1){cntr*=2;continue;}
if(pos==1){if(a[1]>a[0]){
ans+=((a[1]*cntr)%m);
}else{
ans+=((a[0]*cntr)%m);
}
break;
}
ans+=((a[pos]*cntr)%m);
//printf("%d*%d\n",a[pos],cntr);
cntr*=2;
b[pos]=1;
n=pos+1;pos=n/2+1;
}
/*if(n==3){ans+=((a[2]*cntr)%m);cntr++;n--;}
if(n==2){if(a[1]>a[0]){
ans+=((a[1]*cntr)%m);cntr++;
}else{
ans+=((a[0]*cntr)%m);cntr++;
}
}*/
printf("%lld\n",ans);
}
}