JDOJ3008 disc staining

JDOJ3008 disc staining

https://neooj.com/oldoj/problem.php?id=3008

Title Description

The disk is divided into a N (. 1 <= N <= 10 . 5 ) th sector, each sector may be painted red R, yellow G, blue B of one of three colors, but the color of two adjacent sectors must be different, ask how many coating method.

Entry

Enter an integer N, the number of the disk is divided into sectors.

Export

Output an integer representing the N sectors dyed RGB, the number of different colors adjacent sectors embodiment, the answer may be very large, the results of the upper mold 2,333,333.

Sample input

3

Sample Output

 
Disc is stained recurrence of a classic title
Code:
#include<bits/stdc++.h>
int f[100100];   
int main()
{    
    int n;
    scanf("%d",&n);
    f[0]=0;
    f[1]=3;
    f[2]=6;
    f[3]=6;
    for(int i=4;i<=n;i++)
    { 
        f[i]=(f[i-1]+f[i-2]*2)%2333333;
    }
    printf("%d",f[n]);
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/fusiwei/p/11163294.html