解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m = scanner.nextInt(); int[] a = new int[n+1]; int[][] f = new int[n+1][m+1] ; for (int i = 1; i <= n; i++) { a[i] = scanner.nextInt(); } for (int i = 1; i <= a[1]; i++) { f[1][i] = 1; } for (int i = 1; i <= n; i++) { f[i][0] = 1; } for (int i = 2; i <= n; i++) { for (int j = 1; j <= m; j++) { for (int k = 0; k <= a[i]&&k<=j; k++) { f[i][j]=f[i][j]+f[i-1][j-k]; f[i][j] = f[i][j] % 1000007; } } } System.out.println(f[n][m]); } }
0.0分
0 人评分
【计算两点间的距离】 (C语言代码)浏览:927 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:512 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:642 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:388 |
1009题解浏览:802 |
1011题解浏览:819 |
回文数字 (C语言代码)浏览:2539 |
Minesweeper (C语言描述,蓝桥杯)浏览:1176 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:903 |
程序员的表白 (C语言代码)浏览:678 |