Header Ads

Learn Together, Stay Connected.

ট্রিবোনাক্কি-C


#include<stdio.h>
#include<math.h>
unsigned long long int tribo_dp(unsigned long long int n)
{
unsigned long long int trib[n+1];
trib[0]=trib[1]=0;
trib[2]=1;

for(int i=3;i<=n;i++)
{
trib[i]=trib[i-1]+trib[i-2]+trib[i-3];

}
return trib[n];


}
int main()
{
unsigned long long int x;
scanf("%llu",&x);
printf("%llu\n",tribo_dp(x));
return 0;
}

No comments

Theme images by Dizzo. Powered by Blogger.