原创 hdoj1016Prime Ring Problem

經典搜索,打表應該比函數快,因爲最大才20 #include <stdio.h> #include <string.h> int sushu[] = {0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0,  1, 0, 1,

原创 poj 2524 並查集

很水的題,注意輸出格式,冒號後面有一個空格   - - #include <stdio.h> #define maxn 50000 int father[maxn] ; int ans; int find (int x) {while(f

原创 ANDROID drawText實現文字居中

在寬width高height的畫布上畫一字符串,使字符串水平豎直居中:水平居中很簡單,paint.setTextAlign(Align.CENTER);然後drawText的x座標設置爲width / 2即可。

原创 poj2488A Knight's Journey

標準dfs,注意跳出條件 #include <stdio.h> #include <string.h> int xx[8] = {-2, -2, -1, -1, 1, 1, 2, 2}; int yy[8] = {-1, 1, -2,

原创 HDOJ1010DFS

#include <stdio.h> #include <string.h> int dx[4]={1,-1,0, 0}; int dy[4]={0, 0,1,-1}; int ii=0,n,m,t,flag; int map[1

原创 poj1703並查集

#include <stdio.h> #define maxn 330000 int father[maxn],r[maxn];//r[x]表示該節點相對於根節點的位移量,  int find(int x

原创 vijos 1034家族 並查集

經典的並查集,最後確認兩個數是不是親戚的時候要兩個數都要再找一次祖先,一樣的就yes,不一樣就no #include <stdio.h> #define maxn 5000 int father[maxn] ; int find (int

原创 poj 1611The Suspects 並查集

最後輸出的時候注意遍歷每一個數,求每一個數的祖先,如果和0一樣就結果加一 #include <stdio.h> #include <string.h> #define maxn 30000 int father[maxn]; int fi

原创 新博客

來人看一下啊!