Here is the link to the problem:
KFIB Problem - CodeChefproblem statement
my code:
#include<stdio.h>
#include<stdlib.h>
void fibo(int n,long long int k)
{
long long int *a,c ;
a= (long long int*) malloc (sizeof(long long int)*k);
for (long long int i=0;i<k;i++) //T(n,k)=1 when n<=k
{
*(a+i)=1;
}
for (long long int m=k;m<n; m++)
{
c=*(a);
for (long long int j=0;j<k-1;j++)
{
*(a+j)= *(a+j+1);
c=(c+*(a+j))%1000000007ul;
}
*(a+k-1)=c;
}
printf("%lld ",*(a+k-1)%1000000007ul);
free(a);
}
void main()
{
long long int N, K;
scanf(“%lld%lld”,&N,&K);
fibo(N,K);
}
Ive tried a lot but i cannot understand the error.