SHOW:
|
|
- or go back to the newest paste.
1 | #include<stdio.h> | |
2 | #include<math.h> | |
3 | const int MOD = 1000000007; | |
4 | ||
5 | int calc(int a[], int lvl, int num) | |
6 | { | |
7 | long long int d; | |
8 | int i=0; | |
9 | double newa[num]; | |
10 | while(i<num) | |
11 | { | |
12 | newa[i]=log(a[i]); | |
13 | i++; | |
14 | } | |
15 | while(num) | |
16 | { | |
17 | if(newa[num-1]>=newa[num-2]) | |
18 | { | |
19 | d*=(a[num-1]%MOD); | |
20 | newa[num/2]+=newa[num-1]; | |
21 | num=num-2; | |
22 | } | |
23 | else | |
24 | { | |
25 | d*=(a[num-2]%MOD); | |
26 | newa[num/2]+=newa[num-1]; | |
27 | num=num-2; | |
28 | } | |
29 | } | |
30 | return d; | |
31 | } | |
32 | ||
33 | int main() | |
34 | { | |
35 | int d =1; | |
36 | while(d) | |
37 | { | |
38 | scanf("%d",&d); | |
39 | int els; | |
40 | els = (1<<d)-1; | |
41 | long long int val; | |
42 | //printf("%d\n",els); | |
43 | int i=0; | |
44 | int arr[els]; | |
45 | while(i<els) | |
46 | { | |
47 | scanf("%d",&arr[i]); | |
48 | i++; | |
49 | } | |
50 | /* i=0; | |
51 | while(i<els) | |
52 | { | |
53 | printf("%d",arr[i]); | |
54 | ++i; | |
55 | }*/ | |
56 | val = calc(arr,d,els); | |
57 | printf("%lld",val); | |
58 | } | |
59 | return 0; | |
60 | } |