Endl is not working properly

my code is printing 1 2 instead of
[1]
[2]
#include<bits/stdc++.h>
using namespace std;
int tilling(int n,int m)
{
int dp[n];
dp[0]=0;
for(int i=1;i<=n;i++)
{
if(i<m)
{
dp[i]=1;
}
else if(i==m)
{
dp[i]=2;
}
else
{
dp[i]=dp[i-1]+dp[i-m];
}

}
return dp[n];

}
int main() {
int t;
cin>>t;

while(t>0)
{
    int n,m;
cin>>n>>m;
int ans=tilling(n,m);
cout<<ans<<endl;

	t--;
}
return 0;

}

working fine bro

only 1 testcase is passing out of 5