当前位置: 首页 > 工具软件 > Java dollar > 使用案例 >

POJ 3181 Dollar Dayz

夹谷腾
2023-12-01

编程语言:Java
题目链接:http://poj.org/problem?id=3181
题解:属于是java为数不多的优势了
结果:AC

import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
    static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
    static Scanner sc = new Scanner(new BufferedInputStream(System.in));

    public static void main(String[] args) throws IOException {
        BigInteger[] dp=new BigInteger[1003];
        Arrays.fill(dp,BigInteger.ZERO);
        dp[0]=BigInteger.ONE;
        int n=sc.nextInt();
        int k=sc.nextInt();
        for(int i=1;i<=k;i++){
            for(int j=i;j<=n;j++){
                dp[j]=dp[j].add(dp[j-i]);
            }
        }
        out.println(dp[n]);
        out.flush();
    }
}
 类似资料:

相关阅读

相关文章

相关问答