摘要: class Solution { public: int numSquares(int n) { queue<pair<int, int> > pq; //队列中放置一组数据 vector<bool> used(n + 1, false); pq.push(make_pair(n, 0)); while (!pq.empty()) { int num = pq.front().first; int 阅读全文
posted @ 2019-10-05 22:53 pycodego 阅读(400) 评论(0) 推荐(0) 编辑
摘要: package com.array; import java.util.Scanner; import java.util.Vector; class partionArray{ private Vector<Integer>arr=new Vector<Integer>(); private int sum=0; private Scanner iner=new Scanner(System.i 阅读全文
posted @ 2019-10-05 18:24 pycodego 阅读(3512) 评论(0) 推荐(0) 编辑
摘要: import java.util.Scanner; class test { private double dp[];//用来存储每段的最短时间 private double p[];//用来存储每个充电站点离起点的距离 private int n,c,t; private double vr,vt1,vt2; private double Length; public boolean Solut 阅读全文
posted @ 2019-10-05 13:49 pycodego 阅读(246) 评论(0) 推荐(0) 编辑
摘要: package dp; class dpArray{ private int dp[][]; private int w[]; private int v[]; private int memo[]; public int res(){ for(int i=1;i<=4;++i){ for(int j=1;j<=7;++j){ if(j<w[i]){ dp[i][j]=dp[i-1][j]; /* 阅读全文
posted @ 2019-10-05 12:20 pycodego 阅读(262) 评论(0) 推荐(0) 编辑
摘要: class Solutionx{ private int memo[][]; private int w[]; private int v[]; public int bestValue(int Index,int c){ if(Index =w[Index]){ res=Math.max(res, bestValu... 阅读全文
posted @ 2019-10-05 01:09 pycodego 阅读(192) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std; int w[5] = { 0, 2, 3, 4, 5 }; //商品的体积2、3、4、5 int v[5] = { 0, 3, 4, 5, 6 }; //商品的价值3、4、5、6 int bagV = 8; //背包大... 阅读全文
posted @ 2019-10-05 00:08 pycodego 阅读(146) 评论(0) 推荐(0) 编辑