【题目描述】
小明家里现在有nn个苹果,她在每天睡觉之前可以吃1∼21∼2个苹果。小明还有个姐姐May,每天May会等小明睡觉后(为了谦让妹妹)吃11个苹果(如果没苹果的话就不吃)。问总共有多少种吃法。
【输入】
一个整数nn。(0≤n≤100≤n≤10)
【输出】
一个整数,既吃苹果的方案总数。
【输入样例】
5
【输出样例】
4
这道题可以用函数 源代码: #include <bits/stdc++.h> using namespace std; int n; int f(int x) { if( x==0 || x==1 ) { return 1; } if( x==2 ) { return 2; } if( x==3 ) { return 2; } return f(x-2)+f(x-3); } int main( ) { cin>>n; cout<<f(n); return 0; }