Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## Re:贴个很猥琐的脑残代码。。

Posted by 2018213465 at 2019-08-09 10:46:44 on Problem 1351 and last updated at 2019-08-09 10:47:02
In Reply To:贴个很猥琐的脑残代码。。 Posted by:taozifish at 2011-08-17 20:06:04
```> #include<iostream>
> #include<cstdio>
> #include<cstring>
> using namespace std;
> long long s[18][5][4];
> void dp(int x){
>     if(x>=17)return;
>     s[x][1][0]=s[x-1][1][0];
>     s[x][1][1]=s[x-1][1][1]+s[x-1][2][1]+s[x-1][3][1];
>     s[x][1][2]=s[x-1][4][0]+s[x-1][4][2]+s[x-1][1][2];
>     s[x][1][3]=s[x-1][4][1]+s[x-1][1][3]+s[x-1][2][3]+s[x-1][3][3]+s[x-1][4][3];
>     s[x][2][1]=s[x-1][1][0]+s[x-1][4][0]+s[x-1][1][1]+s[x-1][2][1]+s[x-1][3][1]+s[x-1][4][1];
>     s[x][2][3]=s[x-1][1][2]+s[x-1][4][2]+s[x-1][1][3]+s[x-1][2][3]+s[x-1][3][3]+s[x-1][4][3];
>     s[x][3][1]=s[x-1][1][0]+s[x-1][4][0]+s[x-1][1][1]+s[x-1][2][1]+s[x-1][3][1]+s[x-1][4][1];
>     s[x][3][3]=s[x-1][1][2]+s[x-1][4][2]+s[x-1][1][3]+s[x-1][2][3]+s[x-1][3][3]+s[x-1][4][3];
>     s[x][4][0]=s[x-1][4][0];
>     s[x][4][1]=s[x-1][4][1]+s[x-1][2][1]+s[x-1][3][1];
>     s[x][4][2]=s[x-1][1][0]+s[x-1][1][2]+s[x-1][4][2];
>     s[x][4][3]=s[x-1][1][1]+s[x-1][1][3]+s[x-1][2][3]+s[x-1][3][3]+s[x-1][4][3];
>     dp(x+1);
> }
>
> int main(){
>     int i, n;
>     for(i=1; i<=4; i++){
>         if(i==1||i==4){
>         s[1][i][0]=1;
>         s[1][i][1]=0;
>         s[1][i][2]=0;
>         s[1][i][3]=0;
>         }
>         else {
>         s[1][i][0]=0;
>         s[1][i][1]=1;
>         s[1][i][2]=0;
>         s[1][i][3]=0;
>         }
>     }
>     dp(2);
>     while(scanf("%d", &n)&&n>0){
>         long long ans=0;
>         for(i=1; i<=4; i++)ans+=s[n][i][3];
>         printf("%d: %lld\n",n, ans);
>     }
>     return 0;
> }
```

Followed by: