#include<iostream> #include<vector> #include<algorithm> #include<iomanip> #include<string> using namespace std; int main() { int M; while (cin >> M) { if (M == 0) break; long long small = 0; long long big = 1; long long sum = 0; while (M - 1) { M--; long long temp = small; //即将变成大白兔的小白兔数量 small = big; //生下小白兔 big += temp; //长成大白兔 sum = big + small; } cout << sum << endl; } } |
Double click to view unformatted code.