hdu1069Monkey and banana -最大遞增子序列dp

#include<iostream>using namespace std;struct BOX{int l,w,h;}box[200];int dp[200];bool cmp(BOX a,BOX b){if(a.l==b.l)return a.w>b.w;elsereturn a.l>b.l;}int main(){int

pku1029-False coin

pku1029-False coin 題意:一堆硬幣(N個) 中有一個假幣,假幣品質與其他硬幣品質不同(更重或更輕),通過K次稱重得到的結果來判斷假幣的序號。首先給出兩個整數 N 和 K ,表示有N個硬幣,K次稱重。然後2K行每兩行代表一次稱重。1. =等號兩邊的硬幣都是正常硬幣2.<或>同時處於偏重和偏輕端的硬幣正常。#include<stdio.h>#include<string.h>#include<iostream>using

tyvj-1080 鏈表最佳化搜尋

鏈表最佳化搜尋/* * tyvj-1080 * mike-w * 2012-2-3 * ================ * use something like dlx * it's double link list... */#include<stdio.h>#include<stdlib.h>#include<string.h>#define max_size 40int size,total;int

pkupoj1037A decorative fence-動態規劃+字典序計數

pku1037黑書257頁例題有木有啊 別人幾句話就說完了有木有啊完全看不懂有木有啊沒辦法只好上網搜題解啊題解也看了半天啊//我無奈了,,努力了很久還是沒寫出來。不過總算理解了。。。這是努力的結果~#include<iostream>#include<stdlib.h>using namespace std;__int64 W[21][21],M[21][21],c;int used[21],num[21],link[21],list[21],n;__int64

pku1942-Paths on a Grid

本質上是組合數公式 一開始是用搜尋類比 太慢了pku1942Runtime Error#include<iostream>#include<stdio.h>using namespace std;__int64 dfs(__int64 x,__int64 y){if(x==1||y==1) return 1;return dfs(x-1,y)+dfs(x,y-1);}int main(){__int64 m,n;while(scanf("%I64d%I64d",&

PKU2488 A Knight`s Journey–DFS

PKU2488莫名其妙的過了……1.棋盤的布局2.輸出順序3.dir數組表示的方向#include<iostream>#include<stdio.h>#include<string.h>using namespace std;int m,n,flag,dir[8][2]={{-1,-2},{1,-2},{-2,-1},{2,-1},{-2,1},{2,1},{-1,2},{1,2}};bool mp[15][15];char ans[27][2];void

HDU-3339 最短路+背包問題

/* * hdu-3339 * mike-w * 2012-4-14 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE 128#define Q_SIZE 256#define TOTAL_DIST_MAX (MAX_SIZE*MAX_SIZE-100)#define INF 99999999#define min(a,b) ((a)<(b)?(a):(b))#

pku3041-Asteroids 最小點覆蓋

pku3041-Asteroids把行列看成點再用匈牙利演算法過#include<iostream>#include<stdio.h>#include<string.h>using namespace std;bool mp[500][500],visit[500];int link[500];int m,n;bool find(int x){int i;for(i=1;i<=n;i++){if(mp[x][i]&&!visit[i]){

HDU-1050 數學題

此題看來是數學題,有思路很簡單。/* * hdu-1050 * mike-w * 20120-4-8 * ************************************************ * 把每一次移動看成是從S到T繪製一條線段,那麼最少的 * 總移動次數就是線段的最大重疊次數。 * PROOF: * 首先,總移動次數不少於最大重疊次數(記為x),這是明顯的, * 因為重疊的線段每次只能繪製一條。 * 這樣我們只需說明用x次可以繪製所有線段。 * 對於重疊數最大(重疊數記為m)

Wythoff Game(hdu2177)

對於某個局勢(a,b)  ,b>=a差值k=b-a對於某個確定的k有唯一的奇異局勢(必敗點) (a_k,b_k)   其中a_k=k*(1+sqrt(5))/2        b_k=a_k+k如果a,b是奇異局勢 則輸出0不是的話輸出1(通過某種操作可以獲勝)已知a,b 操作分5種1.a==b同時減去a 得到0,02.a==a_k      b>b_kb -(b-b_k)3.a==a_k     b<b_k同時拿走a_k-a_(b-a_k)得到 a_(b-a_k)    a_

pku3083Children of the Candy Corn-類比+bfs

pku3083Children of the Candy Corn類比的部分寫了一下午寫bfs的時候還不知道什麼是bfs……然後去寫bfs模板題(記錄在前兩篇部落格裡)然後貼bfs完成後就一直Runtime Error。。。因為開的數組是 mp[40][40] ,然後資料裡正好有 40*40 就杯具的Runtime

POJ-2236 並查集

不知道STATISTICS中第一頁的程式是怎麼寫出來的。貼上我的950ms+的代碼。/* * wireless network * mike-w * 2012-4-28 */#include<stdio.h>#include<stdlib.h>#include<string.h>#include<math.h>#define MAX_SIZE 1234double co[MAX_SIZE][2]; /* coordinate */int flag[

hdu 2059 龜兔賽跑 動態規劃

hdu 2059龜兔賽跑終於過了 ~ 不容易啊第一次方法錯了,,然後很無奈的上網看了思路 ,我發誓在看見動態規劃四個字之後就把網頁關掉了 然後自己寫。。第一次的代碼://hdu2059 龜兔賽跑 //方法錯 #include<stdio.h>int P[101]={0};int flag[101];main(){int i,j,L,N,C,T,Vr,V1,V2;int x;

pku1015Jury Compromise-最小差最大和dp

pku1015Jury Compromisen組數字,每組兩個數字 d 和 p,要求從中選出m組,使(m個d的和)與(m個p的和)之差最大,如果有種情況的差值相同,取所有d,p總和最大的那種情況。參考#include<iostream>#include<string.h>#include<algorithm>using namespace std;int

hdu1385Minimum Transport Cost-floyd+列印路徑

hdu1385肚子好餓!#include<iostream>#include<stdio.h>#include<string.h>#define M 500#define INF 1000000000using namespace std;int mp[M][M],path[M][M],fee[M];int main(){int

HDU-2844 多重背包

我想知道200ms以內的演算法 也許是單調隊列?還沒學.../* * HDU-2844 coins * mike-w * 2011-10-15 * ---------------- * 多重背包 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAXN 111#define MAXM 100100long N,M;long a[MAXN],c[MAXN];char

hdu2854 Beans 二維dp

hdu2845 Beans 二維動態規劃,先求每一行的最大和,組成新的一行,最後在求這一行的最大和 #include<iostream>#include<string.h>using namespace std;const int INF=200010;int Row[INF][2],Col[INF][2];main(){    int i,j,R,C,temp;    while(scanf("%d%d",&R,&C)!=EOF)    {       

HDU-2444 二分圖匹配

我自己都不知到是怎麼AC的。。。參考了N多代碼才看懂/* * 2444.c * 我用了很長時間才搞明白,唉~~ */#include<stdio.h>#include<stdlib.h>#include<string.h>#define SIZE 222int N,M;int f[SIZE][SIZE];int tag[SIZE];int match[SIZE];int c[SIZE];int DFS(int node,int

HDU-1596 FLOYD

/* * hdu-1596 find the safest road * mike-w * 2012-3-26 ******************************************************** * FLOYD * DON'T chose GCC, or you'll get a TLE */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE

SZNOI-Pack 裝箱問題 題解

題目描述有一個箱子容量為V(正整數,0<=V<=20000),同時有n個物品(0<=n<=30),每個物品有一個體積(正整數)。要求n個物品中,任取若干個裝入箱內,使箱子的剩餘空間為最小。輸入描述第一行為一個整數,表示箱子容量;第二行一個整數,表示有n個物品;接下來n行,分別表示這n個物品的各自體積輸出描述一個整數,表示箱子剩餘空間。範例輸入2468312797範例輸出0這是一道0-1背包的題,雖然都說是用動態規劃,但實際上是窮舉的思路,即把所有的可能都算出來——僅此而已

總頁數: 61357 1 .... 20998 20999 21000 21001 21002 .... 61357 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.