N!

Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 55659    Accepted Submission(s):
15822

Problem Description
Given an integer N(0 ≤ N ≤ 10000), your task is to
calculate N!
 
Input
One N in one line, process to the end of
file.
 
Output
For each N, output N! in one line.
 
Sample Input
1
2
3
 
Sample Output
1 2 6
 
这个题目就是一个大数的乘法,不难,但是半年前的我写这个题目的时候写了很长很长的代码 麻烦的很 花了很久才过的  ,现在想起来就重新写了一遍 代码精简了好多,而且也美观了很多 ,哈哈 事实证明我这半年还是有进步的  O(∩_∩)O!
 
 #include<iostream>
#include<cstdio>
#include<cstring> using namespace std; #define ll long long int num[]; int main()
{
int n;
while(~scanf("%d",&n))
{
memset(num,,sizeof(num));
num[]=;
int pre=;
int len=;
for(int i=;i<=n;i++)
{
pre=;
for(int j=;j<len;j++)
{
num[j]=num[j]*i+pre/;
pre=num[j];
num[j]%=;
}
while(pre>)
{
num[len]=pre/%;
len++;
pre/=;
}
}
for(int i=len-;i>=;i--)
printf("%d",num[i]);
printf("\n");
}
return ;
}

hdu 1042 N!(大数的阶乘)的更多相关文章

  1. HDU 1042 N!(高精度阶乘、大数乘法)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submi ...

  2. HDU 1042 N!(高精度计算阶乘)

    N! Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  3. HDU 1042 大数阶乘

    B - 2 Time Limit:5000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  4. HDU 1042 N! 參考代码

    HDU 1042 N! 题意:给定整数N(0 ≤ N ≤ 10000), 求 N! (题目链接) #include <iostream> using namespace std; //每一 ...

  5. N的阶乘的长度 V2(斯特林近似) 求 某个大数的阶乘的位数 .

    求某个大数的阶乘的位数 . 得到的值  需要 +1 得到真正的位数 斯特林公式在理论和应用上都具有重要的价值,对于概率论的发展也有着重大的意义.在数学分析中,大多都是利用Г函数.级数和含参变量的积分等 ...

  6. WEB前端面试真题 - 2000!大数的阶乘如何计算?

    HTML5学堂-码匠:求某个数字的阶乘,很难吗?看上去这道题异常简单,却不曾想里面暗藏杀机,让不少前端面试的英雄好汉折戟沉沙. 面试真题题目 如何求"大数"的阶乘(如1000的阶乘 ...

  7. C语言求大数的阶乘

    我们都知道如何计算一个数的阶乘,可是,如果这个数很大呢,该如何计算? 当一个数很大时,利用平常的方法是求不出来它的阶乘的,因为数据超出了范围.因此我们要用数组来求一个大数的阶乘,用数组的每位表示结果的 ...

  8. HDU 1018Big Number(大数的阶乘的位数,利用公式)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others) ...

  9. (hdu)1042 N! 大数相乘

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1042 Problem Description Given an integer N( ≤ ...

随机推荐

  1. centos 6.5 安装weixin

    下载cpanm wget http://xrl.us/cpanm --no-check-certificate -O /sbin/cpanm && chmod +x /sbin/cpa ...

  2. -_-#setTimeout与setInterval

    你真的了解setTimeout和setInterval吗? 存在一个最小的时钟间隔 有关零秒延迟,此回调将会放到一个能立即执行的时段进行触发.JavaScript 代码大体上是自顶向下执行,但中间穿插 ...

  3. 后缀自动机(SAM):SPOJ Longest Common Substring II

    Longest Common Substring II Time Limit: 2000ms Memory Limit: 262144KB A string is finite sequence of ...

  4. QDomDocument Access violation writing location

    今天犯了一个非常2的错误! 为了将面板参数保存起来,选择用QDomDocument构造Dom树,然后用doc.toString()方法返回符合xml格式的QString.如: QString CutF ...

  5. 数学概念——H 最美素数

    H - 数论,晒素数 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit S ...

  6. floyd详解

    就不在来回搬了 请看 http://note.youdao.com/groupshare/?token=6422E952998F4381A1534B71359EFA57&gid=1579165 ...

  7. [Locked] One Edit Distance

    One Edit Distance Given two strings S and T, determine if they are both one edit distance apart. 分析: ...

  8. POJ 3187 穷举

    题意:已知有N个数分别为1-N,如下图为4个数.相邻两两相加直至只剩下一个数,下图的结果就是16. 3 1 2 4     4 3 6   7 9 16 现在反过来看,告诉你数的个数N和最终结果,问这 ...

  9. openStack CentOS虚拟桌面iptables初始化配置

  10. JUnit basic annotation

    一个标准的Junit 4的运行流程,大致如下:测试类实例化 -> @BeforeClass -> @Before -> @Test -> @After -> @After ...