解题思路:
逆向思维:不管N是多少,最后一天的桃子数都是固定为1,所以往前倒推N-1 N-2 N-3.........1天吃的桃子数
注意事项:
参考代码:
#include <iostream> using namespace std; int main() { int N; int s = 1; int re = 0; cin>>N; while(1) { re = 2*(s+1); s = re; N--; if(N==1) { break; } } cout<<re<<endl; return 0; }
0.0分
0 人评分