Plz check this code

i am getting the error compilation errors

#include<bits/stdc++.h> using namespace std; double countway(long long n,long long m){ if(n<0||m<0){ return 0; } if(n==0){ return 1; } if(m==0){ return 1; } double a=countway(n-1,m); double b=countway(n-m,m); return a+b; } int main() { int t; cin>>t; while(t–){ long long n,m; cin>>n>>m; cout<<((countway(n,m))%(pow(10,9)+7))<<endl; } return 0; }

Hello @mohitsingh please share it by saving it on ide.codingblocks.com

check this:


but it will still not pass all the test cases because you have to use dynamic programming in this.

but in ques it is said to Print answer for every test case in a new line modulo 10^9+7. and what is the error in my code

10000007 it is not 10^9 +7

Hello @mohitsingh just add 2 more zeroes in between

it is still not passing the test cases and why we can’t we use pow() function here

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

why can’t we use pow function here and how to do it with dp

Actually because of complexity for every call it will calculate power using power that is why it will be not the optimised approach to do like that.

but sir why compilation error in pow function

@mohitsingh that compilation error is because you have not included the particular header file in that.
you can check by adding the header file #inlcude cmath

if you want to do in that way then do lke this:
int m=pow(10,9)+7;

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.