摘要: #include #include using namespace std; class Solution { private: vectorp; vector> res; vectorused; public: void GetPerm(vector&nums,int Index,vector&p) { if (p.size() == 2... 阅读全文
posted @ 2019-10-07 17:37 pycodego 阅读(197) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> using namespace std; const int MAXSIZE = 100; typedef struct SQlist { int arr[MAXSIZE]; int Len; } SQlist; bool Init_SQlist(SQlist &space) { memset(space.arr, 0, sizeof(space.arr)) 阅读全文
posted @ 2019-10-07 17:32 pycodego 阅读(265) 评论(0) 推荐(0) 编辑
摘要: class Solution { private int dp[];//构建一个一维数组来存储次数 public int coinChange(int[] coins, int amount) { if (coins == null || coins.length == 0 || amount == 0) { return 0; } dp=new int[amount+1]; Arrays.sor 阅读全文
posted @ 2019-10-07 15:09 pycodego 阅读(367) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> #define ll long long using namespace std; const int maxn=1010; int c[maxn],w[maxn]; int dp[maxn]; int main(){ int n,v; cin>>n>>v; for(int i=1;i<=n;i++) cin>>c[i]; for(int i=1;i 阅读全文
posted @ 2019-10-07 12:12 pycodego 阅读(411) 评论(0) 推荐(0) 编辑
摘要: Java版的 import java.util.*; class solution { private int T=0; private Scanner iner=new Scanner(System.in); private int v[]=new int[41]; private int c[]=new int[41]; private int s[]=new i... 阅读全文
posted @ 2019-10-06 22:44 pycodego 阅读(176) 评论(0) 推荐(0) 编辑
摘要: dp[i][j]=max{dp[i-1][j-v[i]]+c[i],dp[i-1][j]}; for(i=1;i<=n;i++){ for(j=v[i];j<=v;j++){//注意这里是从v[i]开始到V if(j>=v[i]) dp[j]=max{dp[j],dp[j-v[i]]+c[i]}; } } dp[j]=max{dp[j],dp[j-v[i]]+c[i]}; dp[i][j]=max 阅读全文
posted @ 2019-10-06 16:28 pycodego 阅读(1095) 评论(0) 推荐(0) 编辑
摘要: class Solution{ private int a; private int b; private int sum=0; public Solution(int i,int j) { this.a=i; this.b=j; this.sum=this.a*this.b; } //最大公因数 pu... 阅读全文
posted @ 2019-10-06 15:54 pycodego 阅读(480) 评论(0) 推荐(0) 编辑
摘要: class Solution { private int w[]; private int dp[]; public int numSquares(int n) { w=new int[(int) (Math.sqrt(n)+1)]; dp=new int[n+1]; for(int i=1;i<=Math.sqr... 阅读全文
posted @ 2019-10-06 14:19 pycodego 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(399) 评论(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 阅读(3506) 评论(0) 推荐(0) 编辑