Heritage from father
Problem Description
If you've read this story,you probably know that Harry's parents had left him a lot of gold coins.Hagrid lead Harry to Gringotts(the bank hold up by Goblins). And they stepped into the room which stored the fortune from his father.Harry was astonishing ,coz
there were piles of gold coins.
The way of packing these coins by Goblins was really special.Only one coin was on the top,and three coins consisted an triangle were on the next lower layer.The third layer has six coins which were also consisted an triangle,and so on.On the ith layer there
was an triangle have i coins each edge(totally i*(i+1)/2).The whole heap seemed just like a pyramid.Goblin still knew the total num of the layers,so it's up you to help Harry to figure out the sum of all the coins.
Input
Output
Sample Input
1
3
0
Sample Output
1.00E0
1.00E1
#include<iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
int n,L;
double m,tmp;
while(cin>>n)
{
if(n==0) break; m = log10(n/6.0)+log10(n+1.0)+log10(n+2.0);
L = int(m);
cout<<fixed<<setprecision(2)<<pow(10.0,m-L)<<'E'<<L<<endl;
}
return 0;
}用法:#include <cmath>
功能:计算x的y次幂。
说明:x应大于零,返回幂指数的结果。
Heritage from father的更多相关文章
- hdu 1178 Heritage from father (推导)
题意: 有一个金币堆的金字塔,最上层就有一个金币,以后的i层都是边长为i的实心三角形,给你层数,问:一共有多少个金币?(用科学计数法表示,并且保留两位小数) 解题思路: 根据题意可知求出1*n+2*( ...
- R自动数据收集第一章概述——《List of World Heritage in Danger》
导包 library(stringr) library(XML) library(maps) heritage_parsed <- htmlParse("http://en ...
- POJ3160 Father Christmas flymouse[强连通分量 缩点 DP]
Father Christmas flymouse Time Limit: 1000MS Memory Limit: 131072K Total Submissions: 3241 Accep ...
- Father Christmas flymouse--POJ3160Tarjan
Father Christmas flymouse Time Limit: 1000MS Memory Limit: 131072K Description After retirement as c ...
- father of the archangel of death"?
e wields an axe, a sword and a machine gun and his battlefield pranks have become as legendary as hi ...
- 在包a中编写一个类Father,具有属性:年龄(私有)、姓名(公有); 具有功能:工作(公有)、开车(公有)。 在包a中编写一个子类Son,具有属性:年龄(受保护的)、姓名; 具有功能:玩(私有)、学习(公有)。 最后在包b中编写主类Test,在主类的main方法中测试类Father与类Son。
package a; public class Father { public String name; private int age; public Father(String name) { t ...
- 洛谷P1827 美国血统 American Heritage
P1827 美国血统 American Heritage 54通过 90提交 题目提供者JOHNKRAM 标签USACO 难度普及- 提交 讨论 题解 最新讨论 暂时没有讨论 题目描述 农夫约翰非 ...
- NOIopenjudge 407:Heritage
总时间限制: 5000ms 内存限制: 65536kB 描述 Your rich uncle died recently, and the heritage needs to be divided ...
- USACO3.42American Heritage(二叉树)
已知中前 求后序 递归一下 有一些小细节 /* ID: shangca2 LANG: C++ TASK: heritage */ #include <iostream> #include& ...
随机推荐
- C3P0
c3p0详细配置 官方文档 : http://www.mchange.com/projects/c3p0/index.html <c3p0-config> <default-con ...
- C语言数组
在C语言中,对于三维或三维以上数组的使用并没有很好的支持,而且使用率也非常的低,后面会对三维数组做一些简单的分析,这篇文章主要以二维数组来探讨一些C语言中数组使用的相关概念和技巧. 1 一个var[i ...
- SendMessage发送自定义消息及消息响应
控件向父窗体发送自定义消息,父窗体定义处理此消息的函数 效果描述: 指定哪个类添加自定义消息:(当然这个类必须是CmdTarget的子类,不然不能处理消息) 添加消息 实现消息函数:(wParam ...
- [Ext JS 4] 实战之 Picker 和 Picker Field
前言 所谓的picker , 就是弹出一个选择框,让你选择一些信息.比如选择日期, 选择颜色等: 选择的结果总是要放在一个地方的,Picker Field 就是用来放置选择结果的一个文本框. 在Ext ...
- [置顶] Firefox OS 学习——manifest.webapp结构分析
在Firefox OS 学习——Gaia 编译分析 这篇文章多次提到manifest.webapp文件,对于做过android app 开发的人来说,都很熟悉Android.mk 和Manifest ...
- 使用cacti监控服务器
一.cacti安装 cacti需要lamp环境,因此需要首先编译安装lamp环境,安装完成后,下载cacti的zip包,解压到/www/htdocs目录下,创建cacti需要的数据库. 完成上述后,在 ...
- sql大小转换函数
将字段值转换成大写 UPDATE t SET [name]=UPPER([name]) 将字段值转换成小写 UPDATE t SET [name]=LOWER([name])
- excel删除问号~?~
1.直接替换(菜单)编辑——替换——查找内容——(输入)~?~——替换为(空,就是什么都不输入)——全部替换.2.设原数据在A列,从A1开始,若得到的数值数据需要参与计算,则在B1输入=--LEFT( ...
- 用NMAKE创建VS2012 C++工程 HelloWorld
由于需要精通GDAL的源代码,所以还是有必要精通NMAKE,先来尝试创建一个NMAKE工程. 之前一篇文章Windows7中Emacs 24 shell使用Gitbash已经介绍了如何在Emacs的s ...
- 09_android入门_採用android-async-http开源项目的GET方式或POST方式实现登陆案例
依据08_android入门_android-async-http开源项目介绍及用法的介绍,我们通过最常见的登陆案例进行介绍android-async-http开源项目中有关类的使用.希望对你学习an ...