ZOJ_1216_Deck

zoj 2852 Deck of Cards扑克牌(三维dp) 21-point is a small game played with cards. Its aim is to accumulate the points on the cards so as to get 21 points. This game also appears on some cell phones. To simplify the problem, let's have 阅读详情
Deck

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Scenario

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



题意和思路:这题关键是找规律。。我完全靠凑出来这个规律的,证明为何是这个规律就不知道了,如果哪位达人知道告诉下。最后注意输出格式就好。。找到规律就不难了。


Sample Program Here

/******************************************
**
**      Author: Wan KaiMing
**      Date:   2012-10-31-19.40
**
*******************************************/


#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
int main(){
   int n;//表示牌的数量
   double s=0;//表示超出桌沿的距离
   cout<<"# Cards  Overhang\n";
   while(cin>>n){
     s=0;
     for(int i=1;i<=n;i++) s+=1.0/(2*i);
     cout<<setw(5)<<n
         <<setw(10)<<fixed<<setprecision(3)<<s<<endl;
   }

   return 0;
}


从爱好者到工程师:如何低成本体验RFSoC ZU47DR?性能实测与避坑指南 本文详细介绍了如何低成本体验赛灵思RFSoC ZU47DR芯片,包括二手开发板选购、租赁服务、精简开发环境搭建等实用方案。通过性能实测与避坑指南,帮助爱好者和工程师在有限预算下充分利用这款集成了ARM处理器和FPGA的高性能芯片,降低开发门槛。 阅读详情

相关推荐

详细解读文字识别工具———Tesseract-OCR

   在尝试破解12306验证码的时候,提前了解了一下应对各种验证码的解决方案,这里主要是学习到了面对文字图片验证码,例如亚马逊、豆瓣等平台的登录时会遇到的情况,效果还不错。 一、工具介绍 ​    Tesseract-OCR 是一款由HP实验室开发由Google维护的开源OCR(Optical Character Recognition...

别看我只是一只羊 2万+

zoj1216deck

//关键点推导出公式,啊【】#include #include #include int main() { double card(int n); int n; struct num { double result; int order; struct num *next; } *p,*head,*tail; head = tail = NULL; while(sc

andy的专栏 407

实战分享:如何利用svchost进程绕过360防护(附完整Shellcode注入教程)

本文深入解析系统进程安全防护机制,探讨svchost等关键进程的安全特性与防护策略。详细分析安全软件的行为检测和内存保护技术,提供系统加固与监控实践建议,助力企业构建多层次防御体系,有效应对潜在安全威胁。

weixin_30752699的博客 99

ZOJ 1216 Deck

Deck Time Limit: 2 Seconds      Memory Limit: 65536 KB Scenario 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,

胖子加油! 388

40-Type-C电路设计

Type-C电路设计

weixin_66510961的博客 9649

从‘静态拍照’到‘动态录像’:用Malmquist指数讲好你的效率变化故事(附Stata/R代码)

本文深入探讨了如何利用Malmquist指数构建动态效率分析框架,从静态数据到动态叙事的转变。通过分解技术效率变化(EC)和技术进步(TC),结合Stata/R代码实现四种动态可视化方法,帮助研究者更直观地展示效率变化的动态特征。文章还提供了诊断性叙事结构和比较叙事技巧,助力决策者理解效率提升的来源与趋势。

weixin_32678995的博客 603

ZOJ 1216

<br />这几天真是做这个做上瘾了,估计是beginner的题做的比较H,哈哈。<br />但话又说回来了,尽管都很简单,我还是收获不少。<br /> <br />ZOJ 1216, 放卡片的问题,记得小时候看见这个问题。<br />用递推很容易得到: <br />f(n) = f(n-1) + 1/(2n)<br />f(0) = 0<br /> <br />这样就很容易求解了。<br /> <br />注意到以下几点:<br />1,我用了空间换时间的方法,预先把 n<100000的f(n)都计算出来

bbplayers的专栏 1633

ArcGIS实战:手把手教你用DEM和灾害点数据,5步搞定地质灾害风险区划图

本文详细介绍了使用ArcGIS进行地质灾害风险评估的完整流程,从DEM和灾害点数据出发,通过五步标准化操作生成专业风险区划图。重点讲解了信息量模型的应用,帮助读者掌握GIS技术在地质灾害易发性评价中的实践方法,提升风险评估效率与准确性。

weixin_30696427的博客 424

zoj1216

zoj1216

zzu-hust-madd 487

字节跳动已上岸测试工程师的面试经验

这个时候发面经已经有点晚了,所以现在打算让这篇面经主要面向即将秋招的童鞋,当然现在还在春招的童鞋也可以看哈,我和大家一起聊聊关于测试的二三事。   一、测试工程师的工作是什么?   测试工程师简单点说就是找bug,然后反馈给开发人员,不要小看这个工作。   首先很明显的bug开发人员有时候自己就能找到,测试人员要有比开发人员更加全面的想法才能找到深层次的问题点,   其次,要端正一个态度就是测试人员不是一个电脑小白,相反国外顶级的测试开发工程师同时也是顶级的开发工程师甚至更厉害,所以作为一个测试工程师一定要

m0_60745607的博客 2933

【AutoSAR】【WdgM】WdgM安全管理模块

一、WdgM在AutoSAR里的整体架构 WdgM是在autosar架构里位于服务层的一个基础软件模块;主要监督程序的执行; 主要包括三个模块: 看门狗管理器(WdgM) 看门狗接口(WdgIf) 看门狗驱动(Wdg) 二、三种监督机制 Alive监控-------主要监控周期性软件程序的时间 DeadLine监控-------主要监控非周期软件程序 程序流监控-------主要监控程序流执行的正确性 三、基于全局状态的检测流程 受监管实体(SE):Supervised Ent

专注汽车软件开发、AutoSAR、车载以太网、SOA、EE架构。 2990

1216_Deck

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

李松雨的专栏 332

全面指南:PyTorch与ROCm版本兼容性及多版本环境管理

本文详细介绍了在AMD GPU上配置PyTorch开发环境的完整流程,重点解决版本兼容性和多版本ROCm环境管理问题。主要内容包括:1) PyTorch与ROCm版本对应关系查询;2) 四种查看ROCm版本的方法;3) 使用update-alternatives管理多版本ROCm;4) 环境变量配置与冲突解决方案;5) 完整的验证流程和性能测试方法。文章提供了最佳实践建议和故障排除清单,帮助开发者快速搭建稳定高效的深度学习开发环境,充分发挥AMD GPU硬件性能。通过系统化的验证流程确保各组件协同工作,解决

数字人生 606

zoj1216 Deck

//zoj1216 Deck //1947115 2006-07-15 20:24:46 Accepted 1216 C++ 00:00.01 1172K fairylan #include #define MAXN 100000 double f[MAXN]

fairylan的专栏 1161

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

zoj 1216 Deck

其实题目没看懂   但是知道输入为n   则输出 (1/2)+(1/4)+(1/6)+(1/8).。+(1/(2×n)) 格式有要求   n要右对齐于第5列,长度的小数点要和第12列对齐。。。 所以有 printf("%5d%10.3lf\n",n,s);   #include int main() { int n,i; double s; printf("# Cards

YYlxid————Nothing is possible if not try~ 566

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

ZOJ Problem Set - 1216 Deck

ZOJ Problem Set - 1216 Deck

My world 735

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

ZOJ Problem Set–1216 Deck

Time Limit: 2 Seconds Memory Limit: 65536 KB Scenario 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...

dcl67283的博客 162

ZOJ Problem Set - 1216 Deck

#include <stdio.h> int main() { double table[100001]; double t=2.0; table[1]=0.5; for(int i=2;i<100001;i++) { t+=2; table[i]=table[...

weixin_30652897的博客 105

POJ 1607 /ZOJ 1216 : Deck - 整齐输出

很水的啦。有点像1045那种额。直接等比数列。sum=1/2+1/4+…+1/2*i......注意:POJ 中,G++编译须用f输出; C++编译则用lf输出....否则会wa的。呵呵......水得呀...不过可以学习一下输出位宽整齐的方法。1607Accepted188K32MSC++301B1607Accepted728K32MSG++300B#include#include#includ

Booky的专栏 798

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

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

2074

UVA651 LA5505 POJ1607 ZOJ1216 HDU1330 Deck【数学Ad Hoc】

Deck Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8790 Accepted: 3745 Description A single playing card can be placed on a table, carefully, so that the short edges of the card are par...

海岛Blog 687

Deck

http://acm.hdu.edu.cn/showproblem.php?pid=1330 Deck Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 1437    Accepted Submission(s): 833

ACcoders 935

zoj 1216

输出格式的控制 #include #include double ans[100001]; void get() {     ans[1]=0.500;     for(int i=2;i      ans[i]=ans[i-1]+(1.0/2)*(1.0/i); } int main() {     get();     printf("# Cards  Overh

学习之路 432

ZOJ-1216

import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("# Cards Overhang"); while (sc.hasN

xhldtc的专栏 5137
上一篇: fixed和setprecision等C++格式控制的函数使用
下一篇: ZOJ_1240_IBM Minus One
wankaiming
博客等级 码龄15年 49粉丝 27原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值