Question Link: Link
Editorial Link: Link
Just one friend of mine was implementing the solution given in the editorial of above mentioned question. The implementation of code in python is Link:
def fun(n):
if n<3 :
return 0
return fun(n-2)+(n//2-1)
if __name__ == "__main__":
for _ in range(int(input())):
n=int(input())
print(str(fun(n)))
It gave me a NZEC error, when I converted the above code in C++, then I got AC (Link)
// header file
using namespace std;
int fun(int n){
if( n < 3 )
return 0;
return fun(n-2) + (n/2 - 1);
}
int main(){
int t, n;
cin >> t;
while(t--){
cin >> n;
cout << fun(n) << endl;
}
return 0;
}
I am unable to make out the cause of NZEC. Please help!!!