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. Codeforces Round #246 (Div. 2) —B. Football Kit

    B. Football Kit time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  2. JQuery开发工具和插件

    最近的研究jquery.为大家介绍几款开发工具.能够帮助你提高开发的效率. 1.Dreamweaver Dreamweaver是建立在WEB站点和应用程序的专业工具. 将可视化工具.应用程序开发功能和 ...

  3. javascript它【蛇系列】第一弹:简单的蛇实现

    参考博客:http://blog.csdn.net/sunxing007/article/details/4187038 上面的博客是一个参考,竟第一次做.真让自己盲人摸象做不出来. 只是我在其上做了 ...

  4. Resource temporarily unavailable用户的连接数设置的太小

    -bash:fork:Resource temporarily unavailable的问题   出现这个问题的原因是linux用户的连接数设置的太小,只要修改max user processes就可 ...

  5. 【ASP.NET】怎样使用类创建公共函数,在不同ASP.NET页面间反复调用

    为了降低代码冗余,应将公共函数写在类中,供不同ASP.NET页面调用. 1,先新建一个类,并在类中加入函数逻辑 namespace public_function_demo { public clas ...

  6. hdu 1698 Just a Hook(线段树之 成段更新)

    Just a Hook                                                                             Time Limit: ...

  7. 解决backgroud:transparent在低版本浏览器中的bug

    今天在html页面上定义了一个button和一个div,大小相同,button使用绝对定位,覆盖在div上面一层,同时样式设置背景透明(background:transparent). 这样就可以在看 ...

  8. sql server 行列互转

    1 列转行 测试脚本 ),课程 ),分数 int) ) ) ) ) ) ) go 转化脚本 select 姓名 , end) 语文, end) 数学 , end) 物理 from tb group b ...

  9. WIFI实时监控追踪小车演示视频——安卓端、小车

    文章由@超人爱因斯坦出品,转载请注明出处.         文章链接:          http://hpw123.net/a/qingsongyike/yingyinqu/2014/1019/59 ...

  10. mongodb之java CRUD 简单操作

    我下载的是 mongo-2.8.0.jar — Version 2.8.0 打开mongo shell -- 新建数据库test --( use test) 打开eclipse新建工程,把junit, ...