(HDU)1330 -- Deck (覆盖物)

题目链接:http://vjudge.net/problem/HDU-1330

这题看起来给人晕乎乎的感觉,实际上废话连篇。不建议写。

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cmath>
 4 #include <iostream>
 5 #include <algorithm>
 6 #include <string>
 7 #include <cstdlib>
 8
 9 using namespace std;
10
11 int main()
12 {
13     int n;
14     printf("# Cards  Overhang\n");
15     while(~scanf("%d",&n))
16     {
17         double sum=0;
18         for(int j=1; j<=n; j++)
19             sum+=1.0/(2*j);
20         printf("%5d%10.3lf\n",n,sum);
21     }
22     return 0;
23 }
时间: 2024-07-30 08:38:49

(HDU)1330 -- Deck (覆盖物)的相关文章

HDU - 1330 Deck(物理学力矩)

题意:在桌子边上叠纸牌,使纸牌超出桌边的长度最长,并且不能掉下去. 即重心最多在桌子边缘上,问给你N张纸牌,最长能超出桌子边缘多长. 把第一块木板的重心放在第二块木板的右边缘,把这两块木板的重心放在第三块 木板的右边缘,把这三块木板的重心放在第四块木板的右边缘??利用杠杆原理 可以推出,如果每块木板都是单位长,那么 n 块木板可以伸出桌面 (1 + 1/2 + 1/3 + - + 1/n) / 2 个单位的长度. 最终得到一个递推式:a[i] = a[i-1] + 1.0/i/2 (格式很重要)

POJ1607 &amp; HDU 1330 &amp; ZOJ 1216 Deck(数学题)

题目链接: POJ  1607 : http://poj.org/problem?id=1607 HDU 1330 :http://acm.hdu.edu.cn/showproblem.php?pid=1330 ZOJ  1216 : Description A single playing card can be placed on a table, carefully, so that the short edges of the card are parallel to the table

杭电 HDU ACM 1330 Deck

Deck Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1299    Accepted Submission(s): 749 Problem Description A single playing card can be placed on a table, carefully, so that the short edges o

HDU 1330 Nearest Common Ancestors(求两个点的近期公共祖先)

题目链接:id=1330">传送门 在线算法: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 40010; struct nod{ int to,next,w; }edge[maxn*2]; int head[maxn],ip,tot; bool vis[ma

HDU 1330 Nearest Common Ancestors(求两个点的最近公共祖先)

题目链接:传送门 在线算法: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 40010; struct nod{ int to,next,w; }edge[maxn*2]; int head[maxn],ip,tot; bool vis[maxn]; int R[maxn*2

HDU 2586 + HDU 4912 最近公共祖先

先给个LCA模板 HDU 1330(LCA模板) #include <cstdio> #include <cstring> #define N 40005 struct Edge{ int x,y,d,ne; }; Edge e[N*2],e2[N*2]; int be[N],be2[N],all,all2,n,m; bool vis[N]; int fa[N]; int ancestor[N][3]; int dis[N]; void add(int x, int y, int

HDU——PKU题目分类

HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201

图论 500题——主要为hdu/poj/zoj

转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并查集======================================[HDU]1213   How Many Tables   基础并查集★1272   小希的迷宫   基础并查集★1325&&poj1308  Is It A Tree?   基础并查集★1856   More i

HDU分类

模拟题, 枚举 1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 12