#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#define ll long long
using namespace std;
ll f[];
ll g[];
ll qpow(ll a,ll b){
ll ans=;
while(b){
if (b&==)ans=ans*a;
a*=a;
b/=;
}
return ans;
}
void init(){
f[]=f[]=f[]=;
g[]=;g[]=;g[]=;
for (int i=;i<=;i++){
ll sum=;
for(int j=;j<=i-;j++){
sum=sum+g[j-]*qpow(,i-j-);
}
f[i]=qpow(,i-)+sum;
g[i]=qpow(,i)-f[i];
}
}
int main(){
init();
int n;
while(~scanf("%d",&n)&&n){
printf("%lld\n",f[n]);
}
return ;
}
相关文章
- Codeforces 559C Gerald and Giant Chess【组合数学】【DP】
- Codeforces 711D Directed Roads - 组合数学
- 2018.10.18 NOIP训练 01矩阵(组合数学)
- D - Yet Another Problem On a Subsequence CodeForces - 1000D (DP,组合数学)
- 3997: [TJOI2015]组合数学
- HLG1744组合数学问题与lucas定理运用
- P3813 [FJOI2017]矩阵填数(组合数学)
- UVa 1640 The Counting Problem (数学,区间计数)
- 【搜索】【组合数学】zoj3841 Card
- 2018.10.23 NOIP训练 Leo的组合数问题(组合数学+莫队)