原创 LightOJ 1341 - Aladdin and the Flying Carpet

Sample Input 2 10 2 12 2 Sample Output Case 1: 1 Case 2: 2 題目大意:給你兩個數a和b,a是長方形的面積(這個長方形是非常單純的長方形,他沒有兩條相等的邊),長方形的寬大於

原创 hdu 2669 Romantic(線性同餘,擴展歐幾里得)

題目鏈接http://acm.hdu.edu.cn/showproblem.php?pid=2669 題目大意:找出一組x,y使ax+by=1,如果找不出則輸出“sorry”。 解題思路:有兩個點需要注意,一個點:由定理可得,如果

原创 Poj 1986 Distance Queries

題目鏈接:http://poj.org/status Sample Input 7 6 1 6 13 E 6 3 9 E 3 5 7 S 4 1 3 N 2 4 20 W 4 7 2 S 3 1 6 1 4 2 6 Sample

原创 HDU 2094產生冠軍

原文鏈接:http://www.cnblogs.com/FCWORLD/archive/2011/04/07/2007468.html Sample Input 3 Alice Bob Smith John Alice Smith

原创 Rank of Tetris

原文鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=1811 Sample Input 3 3 0 > 1 1 < 2 0 > 2 4 4 1 = 2 1 > 3 2 > 0 0 > 1

原创 HDU 2647Reward

鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=2647 Sample Input 2 1 1 2 2 2 1 2 2 1 Sample Output 1777 -1 題意:老闆要發工資,

原创 Cube Stacking

Farmer John and Betsy are playing a game with N (1 <= N <= 30,000)identical cubes labeled 1 through N. They start

原创 錢幣兌換問題

錢幣兌換問題 在一個國家僅有1分,2分,3分硬幣,將錢N兌換成硬幣有很多種兌法。請你編程序計算出共有多少種兌法。 Input 每行只有一個正整數N,N小於32768。 Output 對應每個輸入,輸出兌換方法數。 Sample

原创 Invitation Cards dijkstra法

In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware

原创 螞蟻上樹

螞蟻上樹(Sauteed Vermicelli with minced Pork),又名肉末粉條,是四川省及重慶市的特色傳統名菜之一。因肉末貼在粉絲上,形似螞蟻爬在樹枝上而得名。這道菜具體的歷史,已不可考。但在四川省、重慶市一帶

原创 螞蟻覓食

B. 螞蟻覓食(二) 單點時限: 1.0 sec 內存限制: 512 MB 一隻飢餓的小螞蟻外出覓食,幸運的的小螞蟻發現了好多食物。 但是這些食物位於一個N∗M的方格魔法陣的右下角,而小螞蟻位於方格法陣的左上角。 並且小螞蟻被施

原创 暢通工程

某省調查鄉村交通狀況,得到的統計表中列出了任意兩村莊間的距離。省政府“暢通工程”的目標是使全省任何兩個村莊間都可以實現公路交通(但不一定有直接的公路相連,只要能間接通過公路可達即可),並要求鋪設的公路總長度爲最小。請計算最小的公

原创 The King’s Ups and Downs

The King’s Ups and Downs The king has guards of all different heights. Rather than line them up in increasing or d

原创 Zipper

Zipper Given three strings, you are to determine whether the third string can be formed by combining the character

原创 揹包問題彙總

01揹包問題: 無優化: for(int i=1;i<=n;i++) { for(int c=0;c<=m;c++) { f[i][c]=f[i-1][c]; if(c>=w[i])