You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
969 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
/**
1101s10=1.
2s9
39s91s10. s9/2+1: s9-s9/2-1=s9/2-1=s10
4s9=2s10+2
5 Si=2*S(i+1)+2
6Sn=1
*/
/**
*
* @param n
* @return x
*/
int dfs(int x) {
if (x == n) return 1;
return 2 * dfs(x + 1) + 2;
}
int main() {
cin >> n;
//方法1逆推
LL ans = 1; //最后一天剩下一个
for (int i = n - 1; i >= 1; i--) ans = ans * 2 + 2;
cout << ans << endl;
//方法2递归法 顺推
cout << dfs(1) << endl;
//**不管是怎么推,都是要整理出通项公式**
return 0;
}