原创 ZOJ 3778 Talented Chef (貪心+二分)

省賽的時候抽搐了,邊界是max和sum #include <iostream> #include <stdio.h> #include <algorithm> using namespace std; int T, m, n; int

原创 ASP.NET 學習中。。。

開始學習C#了,做的第一款垃圾軟件: http://download.csdn.net/detail/zhoujiachengdhy/7226423 源碼: using System; using System.Collections.

原创 c++ 雜項

const double pi=3.1415926535897932384626; const double e=2.7182818284590452353602; #include <math.h> #include <stdio.h

原创 貪心算法

ZOJ 1029 資源佔用問題 求出最大的重疊次數*10是答案 #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namesp

原创 ZOJ 1009 Enigma

想法很清楚,但代碼不容易實現 保存先 #include<stdio.h> #include<string.h> int m,n,i,j,k,t,iCase; char enigma[3][26]; char input[1000]; in

原创 ZOJ 1007 Numerical Summation of a Series (數學)

思路:基本做法就是一個一個計算,這裏主要考慮的問題就是怎樣減少運算,因爲知道F(1)=1.0,有由f(1)計算f(x)的想法(或減少運算),顯然:f(x)-f(1) = sum( 1/(k*(k+x))-1/(k*(k+1)))=sum(

原创 最長遞增子序列

http://qiemengdao.iteye.com/blog/1660229 I want you! Description Given an array Ai(0<=i<n), its length is

原创 DFS

ZOJ3607 油田問題的變形,主要靠怎麼找到相鄰點對應的相鄰邊 然後進行比較 1.要注意dx dy 與 edge中四個方向匹配,數組下標與座標系的方向是不一樣的 2.f==0&&edge[x][0]==1&&edge[y][2]==1

原创 密文轉換

ZOJ1042 思路:把三種字符分別存儲,在+k1、+k2、+k3後取模 1.要考慮到k1>l1等情況 2.分母不能爲0,否則會出現 Floating Point Error #include<iostream> #include<cs

原创 拓撲排序

 一種拓撲排序算法。該算法是簡單而直觀的,實質上屬於廣度優先遍歷,因此稱爲廣度優先拓撲排序算法。該算法包含下列幾個步驟:             [1] 從有向圖中找一個沒有前趨的結點v,若v不存在,則表明不可進行拓撲排序(圖中有環路),

原创 並查集

FZU2155 帶刪除並查集 HDU 2473 Junk-Mail Filter 並查集刪除(FZU 2155盟國) http://acm.hdu.edu.cn/showproblem.php?pid=2473 http://acm.

原创 數論題

zoj1823 升序方式打印一個數(longlong範圍)的所有素數因子 Sample Input 90 1234567891 18991325453139 12745267386521023 -1 Sample Output 2 3

原创 ZOJ 1100 Mondriaan's Dream

解題報告沒看懂,先存 /* 這至少是一道中等難度的動態規劃題目,首先用面積 的奇偶性,當高度和寬度都爲奇數時顯然答案爲0; 其次,把每一列的磚塊壓縮爲二進制編碼,搜索上一 列到當前列的狀態轉化是否能夠達到,接着DP; 對於每一個位置,

原创 ZOJ 1159 487-3279 (STL)

#include<iostream> #include<stdio.h> #include<string.h> #include<map> #include<string> using namespace std; map<string,

原创 ZOJ 1003 Crashing Balloon(DFS)

#include<iostream> #include<cstring> #include<cstdio> #include<cstdlib> #include<cmath> #include<cmath> #include<string