标签:
input | output |
---|---|
2 10 |
90 |
//0.125 3 854 KB import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in);// 输入 BigInteger dp[][] = new BigInteger[2007][2]; int n, k; n = cin.nextInt(); k = cin.nextInt(); dp[1][0] = (BigInteger.valueOf(k - 1)); dp[1][1] = (BigInteger.valueOf(0)); for (int i = 2; i <= n; i++) { dp[i][0] = (dp[i - 1][0].add(dp[i-1][1])).multiply(BigInteger.valueOf(k-1)); dp[i][1] = (dp[i - 1][0]); } System.out.println(dp[n][0].add(dp[n][1])); } }
ural 1009. K-based Numbers dp 高精度
标签:
原文地址:http://blog.csdn.net/crescent__moon/article/details/43602165