找规律
1 1
#include <iostream>
#include <vector>
using namespace std;
const int maxn=101;
int main()
{
int n;
vector<int> v;
v.push_back(1);
v.push_back(1);
cin>>n;
for(int i=2;i<=n;i++)
{
v.push_back(v[i-1]+v[i-2]);
}
cout<<v[n];
return 0;
}
2 1 1 2
3 111 12 21
4 1111 121 112 211 22
5 11111 122 221 212 1211 2111 1121 1112
v[n]=v[n-1]+V[n-2]
#include <iostream>
#include <vector>
using namespace std;
const int maxn=101;
int main()
{
int n;
vector<int> v(maxn);
v[0]=v[1]=1;
cin>>n;
for(int i=2;i<=n;i++)
{
v[i]=v[i-1]+v[i-2];
}
cout<<v[n];
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
int main()
{
vector <unsigned int> v;
unsigned int n;
v.push_back(0);
v.push_back(1);
for(int i=2; i<50; i++) {
v.push_back(v[i-1]+v[i-2]);
}
while(cin >> n) {
cout << v[n] << endl;
}
return 0;
}