标题:动态规划之钱币兑换问题| 时间限制:1秒| 内存限制:262144K| 语言限制:不限
在一个国家仅有1分,2分,3分硬币,将钱N分兑换成硬币有很多种兑法。请你编程序计算出共有多少种兑法
输入描述:
输入每行包含一个正整数N(0<N<32768)。输入到文件末尾结束。
输出描述:
输出对应的兑换方法数
示例1
输入:2934输出:12553
示例2
输入:718831输出:13137761
题解:
import java.util.Scanner;public class Main_1 {public static void main(String[] args) {Scanner in = new Scanner(System.in);while (in.hasNextInt()) {Integer N = in.nextInt();System.out.println(extracted(N));}}private static Integer extracted(Integer N) {int a = N / 3 + 1;for (int i = 0; i <= N/3; i++) {int t;t = (N - 3 * i) / 2;a += t;}return a;}}