| Task: | Binary tree |
| Sender: | Crisp0r |
| Submission time: | 2019-01-18 12:44:39 +0200 |
| Language: | C++ |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:13:25: error: 'pow' was not declared in this scope
bool arr[(long long)pow(2,N)];
^~~
input/code.cpp:13:25: note: suggested alternative: 'putw'
bool arr[(long long)pow(2,N)];
^~~
putw
input/code.cpp:14:16: error: 'arr' was not declared in this scope
arrptr = &(arr[0]);
^~~
input/code.cpp: In function 'int labi(int)':
input/code.cpp:38:17: error: 'pow' was not declared in this scope
if (node > (pow(2,N-1)-2)){
^~~
input/code.cpp:38:17: note: suggested alternative: 'putw'
if (node > (pow(2,N-1)-2)){
^~~
putw
input/code.cpp:46:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^Code
#include <iostream>
#include <algorithm>
bool* arrptr;
int N;
int labi (int);
int main(){
int M;
std::cin >> N >> M;
bool arr[(long long)pow(2,N)];
arrptr = &(arr[0]);
std::cout << "siin";
for(long long i=0;i<pow(2,N);i++){
arr[i]=1;
}
std::cout << "siin";
for (int i=0;i<M;i++){
int kylg;
std::cin >> kylg;
arr[kylg-1] = 0;
}
long long vasakud = labi(1);
long long paremad = labi(2);
long long tul = (vasakud*paremad)%1000000007;
std::cout << tul*2 << '\n';
return 0;
}
int labi (int node){
if (node > (pow(2,N-1)-2)){
return 1;
} else {
long long sum = 0;
if (*(arrptr+node*2+1))sum += labi(node*2+1);
if (*(arrptr+node*2+2))sum += labi(node*2+2);
return sum%1000000007;
}
}