POJ-1703 並查集

曾經寫過一遍,不過這次似乎寫得更加順暢。注意10^5,是多大……我竟然把MAX_SIZE定義小了一個數量級==!/* * find them, catch them * mike-w * 2012-4-28 */#include<stdio.h>#include<stdlib.h>#include<string.h>#define MAX_SIZE 123456int T,N,M;int diff[MAX_SIZE];int

POJ-1125 FLOYD

為什麼把這個題分到DP的分類中!!!做完本題的感想:1.仔細讀題2.注意資料的格式/* * POJ-1125 stockbroker grapevine * mike-w * 2011-10-23 * ------------------------------ * Note that the time taken to pass the message from person A to person B * is not necessarily the same as the time

歐拉迴路(通路)的輸出

#include<cstdio>#include<cstring>#define MAXN 200struct stack{ int top,node[MAXN];}s;int Edge[MAXN][MAXN];int n;void dfs(int x){ int i; s.top ++; s.node [s.top

hdu2110Crisis of HDU-母函數

hdu2110Crisis of HDU0<pi,mi<10 這個條件貌似不對,用p[i] m[i]分別儲存才過(之前是模板的方法)#include<iostream>using namespace std;int c1[4000],c2[4000],X[101],P[101];int main(){int T,n,m,k,a,b,i,j,num,sum;while(scanf("%d",&n),n){memset(X,0,sizeof(X));for(sum=0

USACO: the perfect stall 二分圖匹配

我對二分圖匹配有了新理解,二分圖的精華在於“二分”這兩個字——整個圖可以被分成兩部分,我們在進行匹配的時候是在分清了二分圖的兩部分後才進行的,就是說:對於一個結點,我們在二分圖匹配的時候已經知道了它的位置,即左邊的半個圖或者右邊的半個圖。此題應是模板題。/*ID: creativ3TASK: stall4LANG: C*//* * USACO: the perfect stall * mike-w * 2011-10-21 * 二分圖匹配 * ps: 剛才我犯了一個愚蠢的錯誤!

HDU 1698(Just a Hook )

#include<stdio.h>#include<string.h>struct node{int a,b,value;}tree[300005];int ans;void maketree(int i,int a,int b){tree[i].a=a;tree[i].b=b;tree[i].value =1;if(a==b)return;int mid=(a+b)/2;maketree(i*2,a,mid);maketree(i*2+1,mid+1,b);}void

SZNOI-Weigh 砝碼稱重 題解

砝碼稱重 設有 1g 、 2g 、 3g 、 5g 、 10g 、 20g 的砝碼各若干枚(其總重 <=1000 ), 要求:     輸入方式: a1  a2  a3  a4  a5  a6              (表示 1g 砝碼有 a1 個, 2g 砝碼有 a2 個,…, 20g 砝碼有 a6 個)     輸出方式: Total=N              ( N 表示用這些砝碼能稱出的不同重量的個數,但不包括一個砝碼也不用的情況) 如輸入: 1_1_0_0_0_0  

HDU 4161(Iterated Difference )

#include<stdio.h>#include<math.h>int num[25];int n;int judge(){int i,k;k=num[1];for(i=2;i<=n;i++){        if(num[i]!=k)break;}if(i<=n)return true;elsereturn false;}int main(){int i,j,k;    int h=0;while(1){scanf("%d",&n);h++;if(

hdu2069Coin Change-母函數

hdu2069錯解//忽略了所有硬幣總數小於100的限制,導致方案數偏大 #include<iostream>using namespace std;int main(){int

HDU-3734 逆序對數

又複習了一遍逆序對數的求法。一個愚蠢的BUG調試了很長時間——printf()寫到大括弧外面了,結果...#include<stdio.h>#include<stdlib.h>#include<string.h>#define lowbit(x) ((x)&(-(x)))#define max_n 1010101typedef struct _node{int num,id;}node;int seq[max_n];node

hdu1398母函數

#include<iostream>using namespace std;int X[18],c1[301],c2[301];int main(){int i,j,num,sum;for(i=1;i<=17;i++)X[i]=500;//printf("!!!!!!!!\n");while(scanf("%d",&sum),sum){memset(c1,0,sizeof(c1));memset(c2,0,sizeof(c2));for(i=0;i<=300;i+

hdu1010-dfs回溯

回溯回溯回溯回溯回溯回溯回溯hdu1010#include<stdio.h>#include<string.h>int abs(int x){return x<0? -1*x:x;}int m,n,T,mp[10][10],Sx,Sy,Dx,Dy,flag,dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}};void dfs(int x,int y,int t){int i,temp;if(x==Dx&&y==Dy&&

HDU-1059 多重背包

更正了自己對多重背包的錯誤處理方法——有收穫!在把多重背包劃歸成0-1背包時要注意劃分方法。/* * HDU-1058 dividing * mike-w * 2011-10-5 * ----------------- * 多重背包 * 原來我對多重背包的處理一直有誤, 今日才發現! */#include<stdio.h>#include<stdlib.h>#include<string.h>#include<assert.h>#define

hdu1028母函數||dp

hdu1028好像母函數的題目都挺簡單的,寫了幾個都是模板另外還有動態規劃的方法#include<iostream>using namespace std;int main(){int X[121],c1[121],c2[121],N,i,j,num;for(i=1;i<=120;i++)X[i]=120;while(scanf("%d",&N)!=EOF){memset(c1,0,sizeof(c1));memset(c2,0,sizeof(c2));for(i=0;

hdu1342&poj2245Lotto – dfs

hud1342dfs第二題 不怎麼熟練看了別人的代碼//hdu 1342 poj2245#include<iostream>#include<stdio.h>using namespace std;int ans[6],S[20];void dfs(int k,int next,int n){int i,j;if(n==7){for(i=1;i<=6;i++){if(i==1)printf("%d",ans[i]);else printf(" %d",ans[i]

HDU 1754(I Hate It )

#include<stdio.h>#include<string.h>struct node{    int a,b,value;}tree[600005];int k;int max(int a,int b){    return a>b?a:b;}void maketree(int i,int a,int b){    if(a==b)    {       tree[i].a=a;       tree[i].b=b;     

hdu2152Fruit-上下限母函數

hdu2152從給出的N種水果中選出限制範圍最大M種然後母函數#include <iostream>#include<algorithm>using namespace std; int N, M;//int A, B;struct fruit{int A,B;}X[101];int a[105], b[105];int c1[105], c2[105];bool cmp(fruit a,fruit b){return

HDU 2851(Lode Runner )

#include<stdio.h>#include<string.h>struct node{ int a,b,value;}p[2005];int min(int a,int b){ return a<b?a:b;}int main(){ int c,i,j,k,n,m,d; int dp[2005]; scanf("%d",&c); for(i=1;i<=c;i++) { scanf("%d%d",&n,&m);

最大連續子串&子矩陣

最大連續子串hdu1003最普通的版本dp[i]=max{ dp[i-1]+dat[i]   , dat[i]   }對於當前的數字dat[i], 有兩種選擇A.原子串增長,dp[i]=dp[i-1]+dat[i]~~~~~前提是dat[i]<=dp[i-1]+dat[i]B.原子串結束,以dat[i]為起點開始新子串。~~~~~前提是dat[i]>dp[i-1]+dat[i]註:以原子串的長度來劃分有三種情況。1.增長 對應上文選擇中的A2.不變

TYVJ-1074 武士風度的牛 BFS

調試了一會,發現程式沒錯,測試資料錯了——讀入的還是上一題的資料==||||還是那句老話——“同學,要細心!”簡單BFS。/* * tyvj-1074 武士風度的牛 * mike-w * 2011-10-26 * --------------------- * BFS */#include<stdio.h>#include<stdlib.h>#include<string.h>#define SIZE 155#define QSIZE

總頁數: 61357 1 .... 20999 21000 21001 21002 21003 .... 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.