Problem Description

Famous Harry Potter,who seemd to be a normal and poor boy,is actually a wizard.Everything changed when he had his birthday of ten years old.A huge man called 'Hagrid' found Harry and lead him to a new world full of magic power. 

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

The input will consist of some cases,each case takes a line with only one integer N(0<N<2^31).It ends with a single 0.

Output

对于每个输入的N,输出一行,采用科学记数法来计算金币的总数(保留三位有效数字)

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的更多相关文章

  1. hdu 1178 Heritage from father (推导)

    题意: 有一个金币堆的金字塔,最上层就有一个金币,以后的i层都是边长为i的实心三角形,给你层数,问:一共有多少个金币?(用科学计数法表示,并且保留两位小数) 解题思路: 根据题意可知求出1*n+2*( ...

  2. R自动数据收集第一章概述——《List of World Heritage in Danger》

      导包     library(stringr) library(XML) library(maps) heritage_parsed <- htmlParse("http://en ...

  3. POJ3160 Father Christmas flymouse[强连通分量 缩点 DP]

    Father Christmas flymouse Time Limit: 1000MS   Memory Limit: 131072K Total Submissions: 3241   Accep ...

  4. Father Christmas flymouse--POJ3160Tarjan

    Father Christmas flymouse Time Limit: 1000MS Memory Limit: 131072K Description After retirement as c ...

  5. 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 ...

  6. 在包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 ...

  7. 洛谷P1827 美国血统 American Heritage

    P1827 美国血统 American Heritage 54通过 90提交 题目提供者JOHNKRAM 标签USACO 难度普及- 提交  讨论  题解 最新讨论 暂时没有讨论 题目描述 农夫约翰非 ...

  8. NOIopenjudge 407:Heritage

    总时间限制:  5000ms 内存限制:  65536kB 描述 Your rich uncle died recently, and the heritage needs to be divided ...

  9. USACO3.42American Heritage(二叉树)

    已知中前 求后序 递归一下 有一些小细节 /* ID: shangca2 LANG: C++ TASK: heritage */ #include <iostream> #include& ...

随机推荐

  1. Ajaxterm

    Index of /software/ajaxterm Ajaxterm Since Mon Feb 28 03:22:42 CET 2011, hosted here: github.com/ant ...

  2. (7)基于hadoop的简单网盘应用实现3

    一.login.jsp登陆界面实现 解压bootmetro-master.zip,然后将\bootmetro-master\src\下的assets目录复制到project里. bootmetro下载 ...

  3. linux上svn连接visual svn server时ssl鉴权失败,问题解决(转)

    场景:1.在windows 7上安装了visual svn server作为自己的svn服务器. 2.在虚拟机centos 6.3上使用svn客户端check代码,报错: [plain] view p ...

  4. [置顶] Android常用适配器控件

    Android常用适配器控件 列表控件用于显示数据集合,Android不是使用一种类型的控件管理显示和数据,而是将这两项功能分布用列表控件和适配器来实现.列表控件扩展了android.widget.A ...

  5. HDSF主要节点解说(二)工作原理

    HDFS(Hadoop Distributed File System )Hadoop分布式文件系统. 是依据google发表的论文翻版的.论文为GFS(Google File System)Goog ...

  6. osx下快捷键相应符号

    2张图展示mac下相应的按键符号: 很多其它文章请前往小胖轩.

  7. Java參数传递方式

    原文:http://blog.sina.com.cn/s/blog_59ca2c2a0100qhjx.html,我作了些改动并添加了一个实例,添加对照 本文通过内存模型的方式来讨论一下Java中的參数 ...

  8. ServiceProvider实现

    ServiceProvider实现揭秘 [总体设计 ] 本系列前面的文章我们主要以编程的角度对ASP.NET Core的依赖注入系统进行了详细的介绍,如果读者朋友们对这些内容具有深刻的理解,我相信你们 ...

  9. WPF界面设计技巧(6)—玩玩数字墨水手绘涂鸦

    原文:WPF界面设计技巧(6)-玩玩数字墨水手绘涂鸦 想让你的程序支持鼠标及手写笔涂鸦吗?只要敲入“<InkCanvas/>”这几个字符,你就会领悟什么叫“很好很强大”,今天我们来做一个手 ...

  10. Java解惑七:很多其它类之谜

    谜题66 继承的问题. 对于实例方法:命名同样时,子类会覆写父类的方法,且訪问权限至少和父类一样大. 对于域:命名同样时,子类会隐藏父类的域,且訪问权限随意. 谜题67 不要重用库中的类名. 谜题68 ...