Time of Update: 2018-12-03
題目連結:(—_—) zZ題目大意:現在又一筆錢, 要買bond,買一個bond要花費一定的錢和這個bond一年結束後可以得到的分紅。每年都是根據上一年最終得到的錢重新買bond,現在要求n年後使最初的那筆錢得到的增長最大。思路: 完全背包。code:#include <stdio.h>#include <string.h>int value[12], interest[12], dp[1000000];int main(){ int i = 0, j = 0,
Time of Update: 2018-12-03
題目連結:(—_—) zZ題目大意: 有n個骨頭, 和一個容量為v的背包, 現在給出每個骨頭的重量和價值, 求在容量為v的背包中能裝的第k大的價值。思路:dp[j][k]表示容量為j時第k大的價值。code:#include <stdio.h>#include <string.h>#include <stdlib.h>int a[32], b[32], w[122], V[122], dp[122][32];int main(){ int i = 0,
Time of Update: 2018-12-03
Problem DescriptionWhereIsHeroFrom: Zty, what are you doing ?Zty: I want to calculate N!......WhereIsHeroFrom: So easy! How big N is ?Zty: 1 <=N <=10
Time of Update: 2018-12-03
~~~題目連結~~~題目大意:先給出一張卡片的長和寬, 現在有n張信封, 每張信封都有一定的長和寬, 現在要求從這些信封中選出最多信封, 從左至右排列, 右邊的信封的長寬都分別大於左邊的, 且卡片能裝入最左邊的信封中。思路:對信封排個序後, 轉化為求最長單調遞增子序列。 和HDOJ 1069思路相差不多code:#include <iostream>#include <algorithm>#define N 5002#define inf
Time of Update: 2018-12-03
~~~題目連結~~~題目大意:給出一個圖形,現要你判斷 它是不是由2個基本圖形(不能旋轉))組合成的。Ps:開始用遞迴進行類比, 老是逾時, 還是用隊友的方法過吧。code:#include <iostream>#include <algorithm>#define inf 1234567890;using namespace std;int n = 0, m = 0, x1 = 0, x2 = 0, y1 = 0, y2 = 0;string m1[12], m2[12
Time of Update: 2018-12-03
Description上次Gardon的迷宮城堡小希玩了很久(見Problem
Time of Update: 2018-12-03
~~~題目連結~~~題目大意:在一個高為h, 寬為w的面板上貼上n張海報, 每個海報的高都為1, 每張海報能儘可能的貼在高度最高的地方, 當同一個高度有多個地方可以貼海報時,貼在最左邊, 現在求每個海報能貼在哪個高度。思路:用線段樹進行2分區間, 把高度看成區間。區間的高度為最小的(h, n), 注意n == 1時;code:#include <stdio.h>#define N 200002#define max(a,b) a>b? a:busing namespace
Time of Update: 2018-12-03
Problem DescriptionA subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another sequence Z = <z1, z2, ..., zk> is a subsequence of X if there exists a
Time of Update: 2018-12-03
前兩天開始人有點不舒服,最早是嗓子有點痛,然後不痛了。接著頭有點痛,這一痛就有點鬱悶了,昨天睡了一天,想想睡一天應該沒有問題了。可是,今天起來頭更痛,去醫院結果是發燒。醫生讓打吊針。打針更鬱悶,我從寢室去醫院的時候,人就是飄的,全身是軟的,走起路來感覺有點晃。然後來到醫院,等醫生等了半天,上班時間不知去什麼地方吹牛去了,汗啊。 然後病人在醫院拿藥,打針,還要自己去跑。這是醫院嘛。什麼服務啊!!!我要是還能跑東跑西,我還用去醫院嘛!!!
Time of Update: 2018-12-03
題目連結:(—_—) zZ題目大意: 有一棵蘋果樹,蘋果樹的是一棵二叉樹,共N個節點,樹節點編號為1~N,編號為1的節點為樹根,邊可理解為樹的分枝,每個分支都長著若干個蘋果,現在要要求減去若干個分支,保留M個分支,要求這M個分支的蘋果數量最多。思路:樹形DP, dp[i][j]表示根節點為i時有j條邊時的蘋果數, 選取左子樹和右子樹有2種情況 1:j條邊全部在左子數或右子數上 2:j條條邊有左子樹和右子樹和起來(這時要分情況討論, 左邊多少條, 右邊多少條, 左邊或右邊最多j-2條,
Time of Update: 2018-12-03
因為開始學習建模,所以就在網上找了一個rational rose但是安裝的時候總是報,unsupport you system.總之就是說不支援你的作業系統(我用的windos xp home)。心裡一灰,google一下找到了一個解決方案: 繞過安裝程式對作業系統版本的檢查。 步驟: 1. 去網上下一個Microsoft Orca,安裝。資料庫編輯器是 Windows Installer SDK 中提供的表編輯工具,可以用於編輯
Time of Update: 2018-12-03
~~題目連結~~題目大意:用()表示空節點, (5)表示一個為5的節點, 5()() 表示葉子節點, 5(2)(6)表示當前節點為5, 左節點為2,右節點為6.現在給出一串字串, 求是否有根節點到分葉節點的值等於給定的值。code:#include <iostream>#include <algorithm>using namespace std;typedef struct node{ int num; struct node *lf, *rt;}Node;
Time of Update: 2018-12-03
http://acm.hdu.edu.cn/showproblem.php?pid=3033借鑒了別人的思路:設計狀態dp[i][j]代表前i組容量為j的最大價值。由於一組裡面有多個物品,所以狀態轉移可以是前一組少取一個,即dp[i-1][p-g[i][j].v]+g[i][j].w,也可以是當前組之前去過的少取一種,即dp[i][p-g[i][j].v]+g[i][j].w。
Time of Update: 2018-12-03
~~~題目連結~~~思路:3 = 1+24 = 2+25 = 2+36 = 3+37 = 2+2+38 = 2+3+39 = 3+3+310 = 2+2+3+3..........通過分解發現把一個數分解成儘可能多的2與3就為最大值。code:#include <stdio.h>#include <string.h>#include <math.h>using namespace std;struct node{ int num[1002];
Time of Update: 2018-12-03
http://acm.hdu.edu.cn/showproblem.php?pid=2955本來轉化成01背包 TLE~~況且浮點數不一定是兩位小數 轉換思想將總的錢數作為背包容量,逃跑成功率為價值,dp[i][j]=max(dp[i-1][j],dp[i-1][v-c[i]]+w[i]); dp[i]表示最大逃跑成功率, 初始化的時候d[0]=1;其餘d[i]=0;即表示搶m錢時的最大成功率#include <iostream>#include
Time of Update: 2018-12-03
for (i=1; i<=n; i++) for (j=m; j>=q[i]; j--)f[j]=max(f[j],f[j-p[i]]+v[i]);要保證動歸方程無後效性j-p[i]一定要比j先算算i時,最小能算到q[i]-p[i]因此以q[i]-p[i]從小到大排序#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>using
Time of Update: 2018-12-03
DescriptionWatashi is the couch of ZJU-ICPC Team and he is very kind hearted. In ZJU-ICPC summer training camp, students are divided into several groups and each day one of the groups will design some problems to hold a contest. Today students of
Time of Update: 2018-12-03
http://acm.hdu.edu.cn/showproblem.php?pid=1203先演算法失敗的機率,找出機率最小的 用1減去就是最大的機率,本來想著用dp[ i ][ j ]表示前 i 個用 j 元的最小機率 轉移方程 dp[i][j]=min(dp[ i-1 ][ j ],,,dp[ i-1 ][ j-cost[i] ]*w[i] )感覺空間太大~~用滾動數組~~#include <iostream>#include <cstdio>#include
Time of Update: 2018-12-03
#include<iostream>#include<cstdio>#include<cstring>#define inf 99999999using namespace std;int dp[100005];int c[100005],w[100005];int main(){int t;scanf("%d",&t);for(;t--;){int e,f;scanf("%d%d",&e,&f);int
Time of Update: 2018-12-03
http://acm.hdu.edu.cn/showproblem.php?pid=3496 二維費用背包實現恰好m控制初始化即可#include <iostream>#include <cstdio>#include <cstring>#define inf 99999999;using namespace std;int dp[1100][110];int c[110];int v[110];int main(){ int t; scanf(