HDU-1427-速算24點http://acm.hdu.edu.cn/showproblem.php?pid=14274個數通過 +,—,*,/和加括弧,計算得24,枚舉數字和運算子,DFS即可,注意題目要求計算過程中都不能出現小數,所以做除法時稍作處理枚舉數組可用algorithm裡的next_permutationThe next_permutation() function attempts to transform the given range of elements [start,
HDU-1598-find the most comfortable roadhttp://acm.hdu.edu.cn/showproblem.php?pid=1598並查集加貪心#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;#define N 1010#define INF 0x7fffffffstruct cam{
http://codeforces.com/problemset/problem/320/AA magic number is a number formed by concatenation of numbers 1, 14 and 144. We can use each of these numbers any number of times. Therefore14144, 141414 and 1411 are magic numbers but 1444, 514 and 414
HDU-4027-Can you answer these querieshttp://acm.hdu.edu.cn/showproblem.php?pid=4027線段樹成段更新,n比較小,更新到每個葉子節點,注意1開根號後仍是1,不需要再更新#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#include<cmath>using
HDU-1298-T9http://acm.hdu.edu.cn/showproblem.php?pid=1298很好的一題,字典樹+DFS,思路參考swm8023大牛的題意是類比手機IME,給出幾個單詞即頻度,再給出幾個數字串,確定對於給定的一個數字串,每輸入一個數字,將顯示什麼字元本題的數字串的每一個數字均代表一個字母,而不是平常的手機,多個數字可能代表一個字母,首先可將給出的單詞即頻度記錄到字典樹中,對於數字串進行DFS,尋找其可能表示的頻度最大的字串例如 ab 2
HDU-4107-Gangsterhttp://acm.hdu.edu.cn/showproblem.php?pid=4107線段樹的成段更新,這題可以記錄一個區間的最大值和最小值,若一個區間的最大值小於p,則增量增加c,若區間的最小值大於等於p,則增量增加2*c,G++逾時,C++過了#include<iostream>#include<cstring>#include<cstdlib>#include<cstdio>#define N 200
HDU-1075-What Are You Talking Abouthttp://acm.hdu.edu.cn/showproblem.php?pid=1075字典樹#include<iostream>#include<cstdio>#include<cstring>#include<cstdlib>using namespace std;struct node{int count;node *childs[26];char