Time Limit: 1
Sec  Memory
Limit: 64 MB
Submit:
23  Solved: 14
[Submit][Status][Web
Board
]

Description

求1!+2!+3!+4!+...+n!的结果。

Input

输入数据含有不多于50个的正整数n(1≤n≤12)。

Output

对于每个n,输出计算结果。每个计算结果应占独立一行。

Sample Input

3 6

Sample Output

9
873

#include
#include
using namespace std;
int main()
{int a,i,n;
double m=1,s=0;
while(cin>>a)
 {s=0;
  for(i=1;i<=a;i++)
  {
  m=1;
  for(n=1;n<=i;n++)
          
m=m*n;
       
s=s+m;}
  cout<<std::fixed<<setprecision(0)<<s<<endl;

}
return 0;
}

随机推荐

  1. xcode project

    An Xcode project is a repository for all the files, resources, and information required to build one ...

  2. 灰度图像阈值化分割常见方法总结及VC实现

    转载地址:http://blog.csdn.net/likezhaobin/article/details/6915755 在图像处理领域,二值图像运算量小,并且能够体现图像的关键特征,因此被广泛使用 ...

  3. H264相关随笔

    DR(Instantaneous Decoding Refresh)--即时解码刷新. I和IDR帧都是使用帧内预测的.它们都是同一个东西而已,在编码和解码中为了方便,要首个I帧和其他I帧区别开,所以 ...

  4. hdu 4472 Count (2012 ACM-ICPC 成都现场赛)

    递推,考虑到一n可以由i * j + 1组合出来,即第二层有j个含有i个元素的子树...然后就可以了.. #include<algorithm> #include<iostream& ...

  5. Beginning Python From Novice to Professional (4) - 演示样本格式字符串

    $ gedit price.py #!/usr/bin/env python width = input('Please enter width: ') price_width = 10 item_w ...

  6. Macosx Setdns

    通过C语言接口在Mac App内部对系统的DNS配置进行改动. Mac OS X设置DNS代码 演示样例代码setDNS.c内容例如以下: #include <SystemConfigurati ...

  7. @font-face(css3属性)实如今网页中嵌入随意字体

    @font-face语法规则 @font-face { font-family: <YourWebFontName>; src: <source> [<format> ...

  8. Welcome Docker to SUSE Linux Enterprise Server【水平有限,中英对比,求纠错】

      原文:Welcome Docker to SUSE Linux Enterprise Server Lightweight virtualization is a hot topic these ...

  9. C#开发Linux守护进程

    用C#开发Linux守护进程   Linux守护进程(Daemon)是Linux的后台服务进程,它脱离了与控制终端的关联,直接由Linux init进程管理其生命周期,即使你关闭了控制台,daemon ...

  10. uva11600 状压期望dp

    一般的期望dp是, dp[i] = dp[j] * p[j] + 1; 即走到下一步需要1的时间,然后加上 下一步走到目标的期望*这一步走到下一步的概率 这一题,我们将联通分块缩为一个点,因为联通块都 ...