原创 usaco ariprog

#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> bool p[125000+10],flag; int n,max,i1; bool pd(

原创 usaco milk3

#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int a,b,c,ans[500],n; short may[30][30][30]; i

原创 維護圖的聯通性

4    維護圖的連通性       Source file:        graph.cpp/pas       Input file:         graph.in       Output file:        graph

原创 usaco calfflac

#include<stdio.h> #include<stdlib.h> char a[20010],b[20010]; int n=0,c[20010],m=0,num1,num2,max=0; bool hw(int x,int y)

原创 km入門-----hdu2255

奔小康賺大錢 問題描述 傳說在遙遠的地方有一個非常富裕的村落,有一天,村長決定進行制度改革:重新分配房子。 這可是一件大事,關係到人民的住房問題啊。村裏共有n間房間,剛好有n家老百姓,考慮到每家都要有房住(如果有老百姓沒房子住的話,

原创 石子合併

#include <stdio.h> #include <stdlib.h> int n,f[101][101],sum[101][101],a[101]; int main() { int i,j,k,t; scanf(

原创 匈牙利算法

#include<stdio.h> #include<stdlib.h> int a[101][101],d[101],m,n,p[101]; int dfs(int x){ int i,j,k; for(i=1;i<=

原创 usaco Friday the Thirteenth

#include<stdio.h> #include<stdlib.h> int m[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int d[7]; main(){ freopen("frida

原创 關於01揹包的問題

01揹包是在M件物品取出若干件放在空間爲W的揹包裏,每件物品的體積爲W1,W2……Wn,與之相對應的價值爲P1,P2……Pn。 問題描述 求出獲得最大價值的方案。 注意:在本題中,所有的體積值均爲整數。 算法分析 對於揹包問題,通常的處

原创 usaco milk

#include<stdio.h> #include<stdlib.h> int p[5010],a[5010],sum=0; int main(){ int n,m; freopen("milk.in","r",stdin); f

原创 vim精通

轉自:http://blog.csdn.net/niushuai666/article/details/7275406# vim的學習曲線相當的大(參看各種文本編輯器的學習曲線),所以,如果你一開始看到的是一大堆VIM的命令分類,你一

原创 noip2015 day1 鬥地主

這道題一看沒有什麼好的算法,就用搜索、 可以先處理出掉牌多的順子。 #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstri

原创 最大公約數gcd.cpp

【問題描述】 對於一個序列 a a a 1 2 , … n ,定義 fi 表示序列前 i 項的最大公約數。我們認爲一個 序列的價值爲 1 n i i f ∑= 。 現在給你一個序列 a a a 1 2 , … n

原创 manacher算法

manacher是一種O(n)尋找回文串的算法; #include<iostream> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #inclu

原创 poj2331 Water pipe IDA*

Description The Eastowner city is perpetually haunted with water supply shortages, so in order to remedy this problem