Heritage from father
来源:互联网 发布:小米手环数据开放 编辑:程序博客网 时间:2024/06/06 04:50
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.
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
130
Sample Output
1.00E01.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应大于零,返回幂指数的结果。
0 0
- Heritage from father
- Heritage from father
- Heritage from father
- Heritage from father
- HDU Heritage from father
- 1178 hdu Heritage from father
- hdu 1178 Heritage from father
- HDU 1178 Heritage from father
- HDU 1178 Heritage from father
- HDU 1178Heritage from father
- HDU 1178 Heritage from father
- hdu---1178Heritage from father
- hdu1178数学题 Heritage from father
- 杭电 - Heritage from father
- hdu(1178)Heritage from father
- Heritage from father HDU1178 居然TLE!!!
- hdu1178——Heritage from father
- HDU 1178 Heritage from father 数学公式 JAVA
- edas提交论文因字体没有内嵌(fonts are not embedded)被拒接提交
- Android布局
- window.showModalDialog以及window.open用法简介
- cmd下查看远程桌面端口
- mongodb 用户 权限 设置 详解
- Heritage from father
- poj 2502 题解 & dijkstra的堆优化
- iOS中消息的传递机制
- python format格式化字符串
- AIX 是什么? AIX和UNIX的关系是什么
- 游走道德法律边缘的超级手机监控
- 从知乎看到的一篇关于学习web前台进程的问题
- HDU1213 How Many Tables
- 内部排序之一:插入排序和希尔排序的N中实现