杭电 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 of the card are parallel to the table‘s edge, and half the length of the card hangs over the edge of the table. If the card hung any further out, with
its center of gravity off the table, it would fall off the table and flutter to the floor. The same reasoning applies if the card were placed on another card, rather than on a table.

Two playing cards can be arranged, carefully, with short edges parallel to table edges, to extend 3/4 of a card length beyond the edge of the table. The top card hangs half a card length past the edge of the bottom card. The bottom card hangs with only 1/4
of its length past the table‘s edge. The center of gravity of the two cards combined lies just over the edge of the table.

Three playing cards can be arranged, with short edges parallel to table edges, and each card touching at most one other card, to extend 11/12 of a card length beyond the edge of the table. The top two cards extend 3/4 of a card length beyond the edge of the
bottom card, and the bottom card extends only 1/6 over the table‘s edge; the center of gravity of the three cards lines over the edges of the table.

If you keep stacking cards so that the edges are aligned and every card has at most one card above it and one below it, how far out can 4 cards extend over the table‘s edge? Or 52 cards? Or 1000 cards? Or 99999?

Input

Input contains several nonnegative integers, one to a line. No integer exceeds 99999.

Output

The standard output will contain, on successful completion of the program, a heading:

# Cards Overhang

(that‘s two spaces between the words) and, following, a line for each input integer giving the length of the longest overhang achievable with the given number of cards, measured in cardlengths, and rounded to the nearest thousandth. The length must be expressed
with at least one digit before the decimal point and exactly three digits after it. The number of cards is right-justified in column 5, and the decimal points for the lengths lie in column 12.

Sample Input

1
2
3
4
30 

Sample Output

The line of digits is intended to guide you in proper output alignment, and is not part of the output that your solution should produce. 

12345678901234567
# Cards  Overhang
    1     0.500
    2     0.750
    3     0.917
    4     1.042
   30     1.997

Source

South Central USA 1998

这个题就是个物理题 ,没啥思路,搜了搜物理解决原理:如果高中物理背景不好 ,下面的话也理解不了。

这是一个非常经典的问题。传统的答案是,把第一块木板的重心放在第二块木板的右边缘,把这两块木板的重心放在第三块木板的右边缘,把这三块 木板的重心放在第四块木板的右边缘??利用杠杆原理可以推出,如果每块木板都是单位长,那么 n 块木板可以伸出桌面 (1 + 1/2 + 1/3 + … + 1/n) / 2 个单位的长度。由调和级数的性质,我们立即可以得知,只要木板数量足够多,木块伸出桌面的长度是没有上界的,想伸出去多长就能伸出去多长。但同时,这个增 长速度也非常缓慢?? 20 块木板只能伸出大约 1.79887
个单位的长度, 1000 块木板也只能伸出大约 4.8938 个单位的长度。

AC CODE:

#include<iostream>
using namespace std;
int main()
{
	int n ;double i;int flag=1;
	while(cin>>n)
	{double sum=0;
		for(i=1;i<=n;i++)
			sum+=1/i;
		sum/=2;
		if(flag)
		{
			cout<<"# Cards  Overhang"<<endl;
			flag=0;
		}
		printf("%5d     %.3lf\n",n,sum);
	}
	return 0;
}
时间: 2024-11-10 12:47:21

杭电 HDU ACM 1330 Deck的相关文章

杭电 HDU ACM 1397 Goldbach&#39;s Conjecture

Goldbach's Conjecture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4976    Accepted Submission(s): 1901 Problem Description Goldbach's Conjecture: For any even number n greater than or equal

杭电 HDU ACM 5186 zhx&#39;s submissions

zhx's submissions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1892    Accepted Submission(s): 507 Problem Description As one of the most powerful brushes, zhx submits a lot of code on many

杭电 HDU ACM 1025 Constructing Roads In JGShining&#39;s Kingdom

Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17732    Accepted Submission(s): 5023 Problem Description JGShining's kingdom consists of 2n(n is no mo

杭电HDU ACM Uncle Tom&#39;s Inherited Land*(二分图匹配 建模)

Uncle Tom's Inherited Land* Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 2496    Accepted Submission(s): 1028 Special Judge Problem Description Your old uncle Tom inherited a piece of land f

杭电 HDU ACM 圆桌会议

圆桌会议 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3356    Accepted Submission(s): 2351 Problem Description HDU ACM集训队的队员在暑假集训时经常要讨论自己在做题中遇到的问题.每当面临自己解决不了的问题时,他们就会围坐在一张圆形的桌子旁进行交流,经过大家的讨论后一般没有

杭电 HDU ACM 1046 Tempter of the Bone

Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 83458    Accepted Submission(s): 22740 Problem Description The doggie found a bone in an ancient maze, which fascinated him a

杭电 HDU ACM 1496 Equations

Equations Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6065    Accepted Submission(s): 2455 Problem Description Consider equations having the following form: a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 a,

杭电 HDU ACM 1283 最简单的计算机

最简单的计算机 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 5238    Accepted Submission(s): 2967 Problem Description 一个名叫是PigHeadThree的研究组织设计了一台实验用的计算机,命名为PpMm.PpMm只能执行简单的六种命令A,B,C,D,E,F:只有二个内存M1,M

杭电 HDU ACM 1213 How Many Tables

How Many Tables Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 17049    Accepted Submission(s): 8349 Problem Description Today is Ignatius' birthday. He invites a lot of friends. Now it's dinn