(from luckycat)
解法:
簡單的DP,要用大數。
注意:
程式碼:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tittle: 10359 - Tiling | |
* Author: Cheng-Shih, Wong | |
* Date: 2015/07/08 | |
*/ | |
import java.util.*; | |
import java.math.*; | |
public class Main { | |
public static void main( String[] args ) { | |
int n; | |
int N = 300; | |
BigInteger[] dp = new BigInteger[N]; | |
dp[0] = BigInteger.ONE; | |
for( int i=1; i < 300; ++i ) | |
dp[i] = BigInteger.ZERO; | |
Scanner input = new Scanner( System.in ); | |
// init | |
for( int i = 0; i<250; ++i ) { | |
dp[i+1] = dp[i+1].add( dp[i] ); | |
dp[i+2] = dp[i+2].add( dp[i].add(dp[i]) ); | |
} | |
// input | |
while( input.hasNext() ) { | |
n = input.nextInt(); | |
// output | |
System.out.println( dp[n] ); | |
} | |
} | |
} |
沒有留言:
張貼留言
任何意見都樂意傾聽