Why getting wrong ans? count Binary Strings

I am using bottom up dp approach.
ways[0] = 1, ways[1] = 2;
then loop for I = 2 to 95 and make ways[I] = ways[I - 1] + ways[I - 2].

code :

using namespace std;

int main() {
	int t; cin >> t;
	int ways[95];
	ways[0] = 1, ways[1] = 2;

	for (int i = 2; i < 95; i++) {
		ways[i] = ways[i - 1] + ways[i - 2];
	}

	while (t--) {
		int n; cin >> n;
		cout << ways[n] << "\n";
	}
	return 0;
}```

@Avi-Kasliwal-315786729062203 make the type of array as long long int.

1 Like