#include<iostream>
using namespace std;
long long num;
long long dp[90];
int solve(int a)
{
dp[0]=1;
dp[1]=1;
for(int i = 2; i<a; i++)
{
dp[i] = dp[i-1] + dp[i-2];
}
return dp[a-1];
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> num;
solve(num);
cout << dp[num-1];//problem.
return 0;
}
because dp size is oversize in int, so i use long long type.
when i using to "cout<< solve(num)", i input value to 47; as a result, i got error(-291928302)
when i use above code("cout << dp[num-1]"), i got normal value.
what are two different?
solve()'s return type isintrather thanlong long.