# 3002. 泰波拿契数列的前74项

#include "bits/stdc++.h"
using namespace std;

uint64_t tribonacci[74]{0, 1, 1}; // Signature

int main() {
for (int i = 3; i < 74; ++i)
tribonacci[i] = tribonacci[i - 1] + tribonacci[i - 2] + tribonacci[i - 3];
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
int n;
cin >> n;
cout << "case #" << i << ":\n" << tribonacci[n] << '\n';
}
}


### include

using namespace std;

### define LL long long

int T,n;
LL a[80];
void solve()
{
cin>>n;
cout<<a[n]<<endl;
}
void init()
{
a[0]=0;a[1]=a[2]=1;
for(int i=3;i<=74;i++) a[i]=a[i-1]+a[i-2]+a[i-3];
return;
}
int main()
{
cin>>T;
init();
for(int step=0;step<T;step++)
{
printf(“case #%d:\n”,step);
solve();
}
return 0;
}

using namespace std;

long long s[74] = { -1 };

long long fb(int n) {
if (s[n] > 0)
return s[n];
if (n <= 1)
return s[n] = n;
else if (n == 2)
return s[n] = 1;
return s[n] = fb(n - 1) + fb(n - 2) + fb(n - 3);
}

int main() {
int t, count = 0;
cin >> t;
fb(73);
while (t–) {
int n;
cin >> n;
cout << “case #” << count++ << “:\n”;
cout << s[n] << endl;
}
return 0;
}

#include <iostream>
using namespace std;

int main()
{
unsigned long long tribonacci[74] = { 0,1,1 };
for (auto i = 3; i < 74; ++i)
tribonacci[i] = tribonacci[i - 1] + tribonacci[i - 2] + tribonacci[i - 3];
int t;
cin >> t;
for (auto z = 0; z < t; ++z)
{
int n;
cin >> n;
cout << "case #" << z << ":" << endl;
cout << tribonacci[n] << endl;
}
return 0;
}


### include

int main()
{
int cas,i,j,temp,carry,n;
scanf(“%d”,&cas);
static int t[100][20]={{0},{1},{1}};
for(i=3;i<100;i++)
{
carry=0;
for(j=0;j<20;j++)
{
temp=t[i-1][j]+t[i-2][j]+t[i-3][j]+carry;
t[i][j]=temp%10;
carry=temp/10;
}
}
for(i=0;i=0;j–)
{
if(t[n][j]) flag=1;
if(flag)
printf(“%d”,t[n][j]);
}
printf(“\n”);
}
return 0;
}