HDU - 1330 Deck(物理学力矩)

题意:在桌子边上叠纸牌,使纸牌超出桌边的长度最长,并且不能掉下去。

即重心最多在桌子边缘上,问给你N张纸牌,最长能超出桌子边缘多长。

把第一块木板的重心放在第二块木板的右边缘,把这两块木板的重心放在第三块

木板的右边缘,把这三块木板的重心放在第四块木板的右边缘??利用杠杆原理

可以推出,如果每块木板都是单位长,那么 n 块木板可以伸出桌面 (1 + 1/2 +

1/3 + … + 1/n) / 2 个单位的长度。

最终得到一个递推式:a[i] = a[i-1] + 1.0/i/2

(格式很重要)

 1 #include<stdio.h>
 2 #include<string.h>
 3
 4 int main(){
 5     double arr[100010];
 6     arr[1]=0.5;
 7     for(int i=2;i<=100000;i++)
 8     arr[i]=arr[i-1]+1.0/i/2;
 9     int n;
10     printf("# Cards  Overhang\n");
11     while(scanf("%d",&n)!=EOF){
12            printf("%5d%10.3lf\n",n,arr[n]);
13     }
14     return 0;
15 }
时间: 2025-01-12 17:06:59

HDU - 1330 Deck(物理学力矩)的相关文章

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 -- 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>

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

从物理学的力矩平衡探讨无铅元件立碑

在SMT制造过程中相当多的企业会碰到立碑现象,特别是在无铅工艺技术应用后,由于无铅锡膏的浸润性变差,这种现象更为突出,工程师们在解决这个问题时方法各异,众多SMT技术论坛有非常多的技术人员在寻找解决方法,为有效解决这种现象,现从力学的观点来具体阐述. 关键词:力矩平衡.无铅器件.立碑 一.概念及故障现象: 什么叫立碑?矩形片式元件的一端在PCB的焊盘上,另一端翘起离开焊盘的现象叫立碑又叫曼哈顿现象.英文中称之为:tombstone或manhattan. 故障现象: 上述图例在很多SMT加工企业都

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