POJ 1607
2013-09-05 19:34
141 查看
Deck
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
Sample Output
Source
South Central USA 1998
1Y直接秒。http://www.guokr.com/article/4437/
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 7686 | Accepted: 3356 |
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
Cards Overhang 1 0.500 2 0.750 3 0.917 4 1.042 30 1.997
Source
South Central USA 1998
1Y直接秒。http://www.guokr.com/article/4437/
#include <cstdio> #include <cmath> #include <algorithm> #include <iostream> #include <cstring> #include <map> #include <string> #include <stack> #include <cctype> #include <vector> #include <queue> #include <set> #include <utility> #include <cassert> using namespace std; ///#define Online_Judge #define outstars cout << "***********************" << endl; #define clr(a,b) memset(a,b,sizeof(a)) #define lson l , mid , rt << 1 #define rson mid + 1 , r , rt << 1 | 1 #define mk make_pair #define FOR(i , x , n) for(int i = (x) ; i < (n) ; i++) #define FORR(i , x , n) for(int i = (x) ; i <= (n) ; i++) #define REP(i , x , n) for(int i = (x) ; i > (n) ; i--) #define REPP(i ,x , n) for(int i = (x) ; i >= (n) ; i--) const int MAXN = 400000 + 150; const int sigma_size = 26; const long long LLMAX = 0x7fffffffffffffffLL; const long long LLMIN = 0x8000000000000000LL; const int INF = 0x7fffffff; const int IMIN = 0x80000000; #define eps 1e-4 const int MOD = (int)1e9 + 7; typedef long long LL; const double PI = acos(-1.0); typedef double D; typedef pair<int , int> pi; ///#pragma comment(linker, "/STACK:102400000,102400000") int main() { int n; double ans; printf("Cards Overhang\n"); while(~scanf("%d" , &n)) { ans = 0.0; FORR(i , 1 , n) { ans += 1.0 / (2 * i); // cout << ans << endl; } printf("%5d %.3lf\n" , n , ans); } return 0; }
相关文章推荐
- poj1607
- POJ&nbsp;1607
- poj 1607 Deck(坑爹的水题啊)
- poj/pku 1607
- POJ 1607
- POJ 1607 /ZOJ 1216 : Deck - 整齐输出
- 基因匹配度计算 poj 1080
- poj 1724 有限制的最短距离(优先队列+链表)
- POJ 1007 DNA Sorting
- POJ 1269 Intersecting Lines
- poj 1011
- poj 1185 炮兵阵地 状态压缩dp
- poj 3196(水数学)
- POJ-3345 Bribing FIPA(Tree dp + 背包)
- POJ2752 Seek the Name,Seek the Fame KMP算法
- POJ 1698 Alice's Chance
- poj_2935 Basic Wall Maze
- poj 1135 Domino Effect (dijkratra算法)
- poj1012-Joseph(输出出列编号模板)
- POJ 2253 Frogger (Floyd 松弛操作)