hdu 4612——Warm up

tarjan縮點+樹的直徑https://www.byvoid.com/blog/scc-tarjan/    講tarjian比較好http://blog.csdn.net/u010638776/article/details/9472605   借鑒了這裡 #include<iostream>#include<cstdio>#include<cstdio>#include<queue>#pragma comment(linker,

poj 2186——Popular Cows

 tarjan縮點題意:有n個牛,m個關係。並且如果a->b  b->c  則a->c.先用tarjan把各個強連通分量縮成一個點,(這個點裡的奶牛互相仰慕)並且記錄下各個強連通分量裡點的個數。找出出度為0的強連通分量,若只有1個,則輸出該強連通分量裡點的個數。若找到多個出度為0的強連通分量,輸出0. //148K 16MS

poj 1236——Network of Schools

tarjan演算法注意:如果是強連通圖的化輸出0 1通過tarjan演算法縮點。第一問輸出入度點=0的個數。第二問中添加的邊數是max(入度點=0的個數,出度點=0的個數)。 暫且當定理記下。#include<iostream>#include<cstdio>#include<cstring>using namespace std;#define maxm 21000#define maxn 220int n;int head[maxn],cnt;int v[

hdu 1394——Minimum Inversion Number

線段樹//31MS 340K c++#include<iostream>#include<cstdio>using namespace std;#define maxn 5010#define ls (rt<<1)#define rs (rt<<1|1)#define mid ((t[rt].l+t[rt].r)>>1)struct tree{int l,r;int sum;}t[maxn<<4];int num[maxn]

poj 2883——Points

差分約束注意點是要建立一個超級原點 防止有多個分圖出現#include<queue>#include<iostream>#include<cstdio>using namespace std;#define INF 10000001#define esp 1int n,m;int head[2][30015],v[2][30015],next[2][30015];double w[2][30015];double dis[1005];int input[150

hdu 4635——Strongly connected

tarjan演算法最終添加完邊的圖,肯定可以分成兩個部X和Y,其中只有X到Y的邊沒有Y到X的邊,那麼要使得邊數儘可能的多,則X部肯定是一個完全圖,Y部也是,同時X部中每個點到Y部的每個點都有一條邊,假設X部有x個點,Y部有y個點,有x+y=n,同時邊數F=x*y+x*(x-1)+y*(y-1),整理得:F=N*N-N-x*y,當x+y為定值時,二者越接近,x*y越大,所以要使得邊數最多,那麼X部和Y部的點數的個數差距就要越大,所以首先對於給定的有向圖縮點,對於縮點後的每個點,如果它的出度或者入度

sgu 330——Numbers

DescriptionYoung Andrew is playing yet another numbers game. Initially, he writes down an integerA. Then, he chooses some divisor d1 ofA, 1 <     d1 <   A, erases A and writes A1=A+    d1 instead. Then, he chooses some divisord2 of A1, 1 <  

hdu 4607——Park Visit(暑假第一次多校)

樹的直徑求出樹的直徑後分類討論。#include<iostream>#include<cstdio>#include<cstring>#include<queue>using namespace std;#define maxn 200005int head[maxn];int v[maxn],next[maxn],cnt;int n,m,r;void add(int x,int

hdu 4602——Partition

找規律a(n)=(n+3)*2^(n-2)         a(n+1) = 2*a(n) + 2^(n-1)  a0=1 a1=21 2 5 12 #include<iostream>#include<cstdio>#include<cstring>using namespace std;#define mod 1000000007#define LL __int64LL Pow(LL n){ if(n==1) return 2;

Quantity Of The Stones

Quantity Of The Stones Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 45   Accepted Submission(s) : 11Font: Times New Roman | Verdana | Georgia Font Size: ← →Problem Description  xysDavidCN

hdu 5611——Balls Rearrangement

http://blog.csdn.net/dyx404514/article/details/9474251上面的那個很好的解釋了。以11 5 3 為例  5 3 的最小公倍數151  2  3  4  5  6  7  8  9 10 11 12 13 14 150 1  2  3  4  0  1  2  3  4   0   1   2   3   4  放進a箱子 i%5的值以5為迴圈 0  1  2  0  1  2 0  1  2  0   1   2   0 

樹狀數組模型

模板1:改點求段http://acm.hdu.edu.cn/showproblem.php?pid=1166  hdu 1166 敵兵布陣#include<iostream>#include<cstdio>#include<cstring>using namespace std;int a[50004],n;char str[20];int lowbit(int i){return i&(-i);}int Sum(int i){int

預存程序接收多個值(用分隔字元號的字串參數)的用in查詢

--這個是截取字串的函數,在產生預存程序的時候調用了gocreate function [dbo].[f_split](@SourceSql varchar(max),@StrSeprate varchar(10))    returns @temp table(Rowvalue varchar(1000))as     begin        declare @i int        set @SourceSql=rtrim(ltrim(@SourceSql))        set

hdu 2491 pingpong

樹狀數組。#include<iostream>#include<cstdio>#include<cstring>using namespace std;#define maxn 100006int a[maxn];int n=maxn;int lowbit(int i){return i&(-i);}int Sum(int i){int sum=0;while(i>=1){sum+=a[i];i-=lowbit(i);}return

JQuery 載入部落格園首頁的RSS

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html;

Find the nondecreasing subsequences HDU 2227

樹狀數組#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define maxn 100006int a[maxn];int n=maxn;struct Note{int val,ord;}b[maxn];bool cmp(Note a,Note b){return a.val<b.val;}int

poj 1201——Intervals

差分約束建圖spfa求的最長路徑 #include<iostream>#include<cstdio>#include<queue>#include<cstring>using namespace std;#define INF 100000int head[151000],v[151000],w[151000],next[151000];int dis[51000];bool vis[51000];int cnt,n,m;void

poj 1716 ——Integer Intervals

差分約束#include<iostream>#include<cstdio>#include<cstring>#include<queue>using namespace std;#define INF 10000001int n,m;int head[30015],v[30015],w[30015],next[30015];int vis[10015],dis[10015];int cnt;void add(int a,int b,int c){

poj 3169——Layout

查分約束 #include<iostream>#include<cstdio>#include<cstring>#include<queue>using namespace std;#define INF 1000001int head[30000],v[30000],w[30000],next[30000];int dis[2000],vis[2000],output[2000];int cnt,n,l,d;void add(int a,int

poj 2983——Is the Information Reliable?

差分約束#include<cstdio>#include<iostream>#include<cstring>#include<queue>using namespace std;#define INF 10000001int n,m,cnt;int head[350001],v[350001],w[350001],next[350001];int dis[1005],vis[1005],output[1005];void add(int

總頁數: 61357 1 .... 19116 19117 19118 19119 19120 .... 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.