题解 | #吃糖果#
吃糖果
https://www.nowcoder.com/practice/72015680c32b449899e81f1470836097
//建设有N块,则当天吃一块对应dp(N-1),吃两块对应dp(N-2)。按照地递推关系递推即可
#include "stdio.h"
int dp(int N){
if(N == 1)
return 1;
if(N == 2)
return 2;
return dp(N-1)+dp(N-2);
}
int main(){
int N;
while (scanf("%d",&N)!=EOF){
printf("%d\n", dp(N));
}
}


阿里巴巴灵犀互娱公司福利 654人发布