原创 hdoj2049(考新郎

#include <stdio.h> long long int fact(int n) { long long int s=1; if(n==0) s=1; else {

原创 hdoj2053(switch game

#include <stdio.h> #include <math.h> int main() { int n; while(scanf("%d",&n)!=EOF) { int ans1;

原创 hdoj2048(神、上帝以及老天爺

#include <stdio.h> int main() { int c,n; long long int a[1000]; long long int b[1000]; double ans;

原创 hdoj2041(走樓梯 實爲Fibonacci數列

#include <stdio.h> int main() { int n,m; int s[1000]; while(scanf("%d",&n)!=EOF) { s[2]=1;

原创 hdoj2047(EOF牛肉串

#include <stdio.h> int main() { int n; long long int a[1000]; a[1]=3; a[2]=8; while(scanf("%d",&n)!

原创 hdoj2036 c語言實現(任意多邊形的面積

#include <stdio.h> #include <stdlib.h> int main() { int n; int x[1000]; int y[1000]; while(scanf("

原创 hdoj1004(let the ballooon rsie

#include <stdio.h> #include <stdlib.h> #include <string.h> char balloon[1001][1001]; int count[1001]; int flag[1001]; i

原创 [HDOJ] 2191 悼念512汶川大地震遇難同胞——珍惜現在,感恩生活 [多重揹包+二進制優化]

題意:有經費n,有m種大米,大米只能整袋買,每種大米已知每袋重量,每袋的價格及對應的袋數,用有限的經費儘可能的去購買更多的大米。 思路:多重揹包+二進制優化 題目給的數據比較小,如果是不優化直接做的話應該也能過,但用了二進制優化後用01揹

原创 hdoj1002(A+B problem II 大數相加 c語言

#include <stdio.h> #include <string.h> #include <stdlib.h> char a[10000],b[10000],c[10000]; char a1[10000],b1[10000]; c

原创 poj 1751 Highways prim算法

題目的大意就是說給你幾個點的座標,並且有幾個點之間路是已經修好了的,讓你加入其他的邊,使得邊權和最小,最小生成樹的問題,只是初始給了你固定的幾條邊而已。用prim算法比較好,因爲prim算法比較適合稠密圖,kruskal算法更適合稀疏圖,

原创 POJ 2676 Sudokou DFS

題目就是解數獨 思路很直接:DFS 用row[i][x] //表示第i行中x出現過      col[j][y]//表示第j列中y出現過     grid[k][z]//表示第k個格子z出現過     k=3*((i-1)/3)+(j-

原创 [CodeForces] 510 C Fox And Names [拓撲排序]

題意:給定n個字符串,問能不能求出一個字母表使得字符串滿足字母表上面的字典序 思路:拓撲排序,但是這個題目的坑有點多 比較坑的就是aa a這種情況是錯誤的 因爲aa的字典序明顯比a要大 <pre name="code" class="c

原创 hdoj2073(無限的路

#include <stdio.h> #include <math.h> #include <stdlib.h> #include <string.h> double a[200][200]; int main() { a[0]

原创 [POJ] 1201 Intervals [差分約束]

題意:給出數軸上的n個區間[ai,bi],每個區間都是連續的,Z集合由一堆數軸上面的元素組成,Z裏面的元素和[ai,bi]的交集有ci個元素,問Z裏面至少有多少個元素; 思路 :差分約束;用一個數組Dis[x]表示從0到x一共有多少個Z裏

原创 hdoj2061(GPA

#include <stdio.h> int main() { int n; scanf("%d",&n); while(n--) { int count;