原创 USACO 2.3 Cow Pedigrees (nocows)
//Main idea: //Dynamic Programming //dp[i][j] denote the number of binary trees whose node number is i and height is l
原创 USACO 2.4 Bessie Come Home (comehome)
//Main idea //Calculate the shortest path from 'Z' to ohter pastures by Dijkstra algorithm; //And then choose shortest
原创 USACO 2.3 Controlling Companies (concom)
//Main Idea: //brute force; //shares[i][j] is the initial shares company i own for company j; //fianl_shares[i][j] is t
原创 USACO 2.4 Overfencing (maze1)
//Main idea //First we find the two exits and use flood fill to calculate their distance //to any other block;Compare e
原创 USACO 2.3 Money Systems (money)
//Main idea: //Dynamic Programming //dp[i][j] denote the number of ways to construct money j by coins[0...i] //state t
原创 USACO 2.2 Party Lamps (lamps)
//Main idea: //Reading the problem condition, we can know that //1: the order we press the button mean nothing for the
原创 USACO 2.3 Zero Sum (zerosum)
//Main Idea: //Search by DFS; //In ASCII order means that cout the sum of string's ASCII value, and sort //them in asce
原创 USACO 3.1 Shaping Regions (rect1)
/* 思路大概是這樣的,首先讀入所有的矩形。我們可以發現最後覆蓋的矩形不會被其他矩形覆蓋,所以可以考慮從後向前覆蓋。 對於每個矩形,我們把它和有可能覆蓋在它上面的矩形(就是出現在當前矩形後面的矩形)比較, 如果兩個矩形有重疊部分就把重疊部
原创 USACO 3.1 Humble Numbers (humble)
/* usaco official solution We compute the first n humble numbers in the "hum" array. For simplicity of implementation,
原创 USACO 2.4 Cow Tours (cowtour)
//Main Idea //Use floyd algorithm to calculate shortest path of each pair of pastures //The compute the smallest possi
原创 USACO 3.2 Factorials (fact4)
/* F[i] denote the 5 digits from rightmost non-zero digit of i! ; There is a trap, we can't just store the rightmost no
原创 USACO 2.4 The Tamworth Two (ttwo)
//Main idea: //brute force //We use record[farmer.x][farmer.y][cows.x][cows.y][farmer.direct][cows.direct] to record /
原创 USACO 2.2 Runaround Numbers (runround)
//Main Idea //First check whether the digits are unique //then check the runround property; /* ID: haolink1 PROG: runr
原创 USACO 3.1 Stamps (stamps)
/* Main idea: This is a good Dynamic programming problem; dp[i]=min{dp[i-value[j]]}+1 // (j=1..n and i-value[j]>=0) d
原创 USACO 3.1 Agri-Net (agrinet)
//Main idea //Minimun Spannig Tree, we use Kruskal's algorithm; /* ID: haolink1 PROG: agrinet LANG: C++ */ //#include