自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(7)
  • 收藏
  • 关注

原创 划分数——java

在解这道题之前,我们先看一道跟这道题很像的题目: 把m个同样的苹果放在n个同样的盘子里,允许有的盘子空着不放,问有多少种不同的分法?(注:5,1,1和1,1,5是同一种分法) 问题分析: f(m,n): 表示把m个苹果,放入n个盘子的分配方法总数 1.当m = 0或 n = 1时,只有一种分法 2.当m < n 时,即当苹果数少,盘子过剩时。此时一定有n-m个盘子一直空着,去掉他们对于分配的总数没有影响。 if(m < n) f(m,n) = f(m,m); 3.当 m >= ..

2020-07-20 22:05:38 131

原创 最长上升子序列问题

问题分析: dp[i] : 以a[i]结尾的最长上升子序列的长度 递推公式: import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for(int i = 0;i < n;i++) { a[i] = .

2020-07-18 15:37:12 171

原创 完全背包问题——Java

import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] w = new int[n]; int[] v = new int[n]; for(int i = 0;i < n;i++) { w[i] = sc.nextInt(); v[..

2020-07-17 14:17:29 888

原创 0-1背包问题——java

解法一: dp[i][j] : 从第i个物品开始挑选总重小于j时,总价值的最大值 递推式: 代码: import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] w = new int[n]; int[] v = new int[n]; for(int i.

2020-07-15 16:05:48 206

原创 最长公共子序列问题——(java)

问题分析: dp[i][j]:s1 ,s2,…,si和t1,t2,…,tj对应的最长公共子序列 因此,对于s1 ,s2,…,si,s(i+1)和t1,t2,…,tj,t(j+1)对应的最长公共子序列是: 当s(i+1) == t(j+1)时,在s1 ,s2,…,si和t1,t2,…,tj的最长公共子序列加上s(i+1)或t(j+1) s1 ,s2,…,si和t1,t2,…,tj,t(j+1)的最长公共子序列 s1 ,s2,…,si,s(i+1)和t1,t2,…,tj的最长公共子序列 递推公式: 代码: .

2020-07-14 16:08:20 236

原创 Saruman‘s Army(POJ3069-Java)

Description Saruman the White must lead his army along a straight path from Isengard to Helm’s Deep. To keep track of his forces, Saruman distributes seeing stones, known as palantirs, among the troops. Each palantir has a maximum effective range of R unit

2020-07-05 21:26:38 124

原创 Best Cow Line(POJ3617)Java实现

Description FJ is about to take his N (1 ≤ N ≤ 2,000) cows to the annual"Farmer of the Year" competition. In this contest every farmer arranges his cows in a line and herds them past the judges. The contest organizers adopted a new registration scheme this

2020-07-02 21:41:55 2904

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除