http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=714&page=show_problem&problem=841

#include <cmath> #include <ctime> #include <iostream> #include <string> #include <vector> #include<cstdio> #include<cstdlib> #include<stack> #include<queue> #include<map> #include<algorithm> #include<sstream> #include<cstring> #define For(i,n) for(int i=0;(i)<n;i++) #define mp make_pair #define pb push_back #define MOD 10000007 using namespace std; int main(){ int p[]={3,6}; int *t=p; int x=*t++; cout<<*t<<x; long long int dp[101][4]; memset(dp,0,sizeof(dp)); dp[1][0]=1;dp[1][1]=1; dp[2][0]=2;dp[2][1]=1;dp[2][2]=1; For(i,101){ if(i<3)continue; For(j,3){ dp[i][0]+=dp[i-1][j]; } dp[i][1]=dp[i-1][0]; dp[i][2]=dp[i-1][1]; dp[i][3]=dp[i-1][2]+2*dp[i-1][3]; } int n; cin>>n; while(n!=0){ cout<<dp[n][3]<<endl; cin>>n; } }

## No comments:

## Post a Comment