Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=1330
Analysis: Classic question,n block the same board overlap, up to reach the desktop how far
For the best pendulum of n cards, we only need to add a card with an edge to the table eaves under the pendulum of the n-1 card and move all the cards out to the eaves. For a best pendulum, its center must be on the table eaves, so must conform to the principle of leverage, the fulcrum is the table eaves. So for the case of n cards, we assume that the nth sheet moves outward x, then the center of gravity of the front n-1 is outside the table eaves X, because their center of gravity is on the table eaves when n-1 card. The center of gravity of the nth card is 0.5-x in the eaves of the table, so we can list the lever balance equation: (0.5-x) *1=x* (n-1)
Solution: x=1/(2n). Can be launched, if each plank is a unit length, then n pieces of wood can be stretched out of the table (1 + 1/2 +
1/3 + ... + 1/n)/2 units of length.
Reference: http://gd2011.teacher.com.cn/UserLog/UserLogComment.aspx?UserlogID=15319
#include <cstdio>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>#include<queue>#include<cstdlib>#include<vector>#include<Set>#include<map>#defineLL Long Long#defineINF 1<<30#defineMoD 1000000007#defineN 100010using namespacestd;intMain () {intN; Doublea[100010]; a[1] =0.5; for(inti =2; I <=100000; i++) A[i]= a[i-1] +1.0/i/2; printf ("# Cards overhang\n"); while(SCANF ("%d", &n) >0) {printf ("%5d%10.3lf\n", N,a[n]); }}View Code
hdu1330 (Recursive)