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. [Locked] Wiggle Sort

    Wiggle Sort Given an unsorted array nums, reorder it in-place such that nums[0] <= nums[1] >= ...

  2. Django教程:第一个Django应用程序(3)

    Django教程:第一个Django应用程序(3) 2013-10-08 磁针石 #承接软件自动化实施与培训等gtalk:ouyangchongwu#gmail.comqq 37391319 #博客: ...

  3. VS2008 error C2470

    error C2470: '***类' : looks like a function definition, but there is no parameter list; skipping app ...

  4. Appium移动自动化测试(四)--one demo(转)

    Appium移动自动化测试(四)--one demo 2015-06-15 20:41 by 虫师, 40514 阅读, 34 评论, 收藏, 编辑 继续更新. ------------------- ...

  5. vue.js学习笔记(一):什么是mvvm框架,vue.js的核心思想

    一:MVVM框架 MVVM框架的应用场景:  1.针对具有复杂交互逻辑的前端应用 2.提供基础的架构抽象 3.提供ajax数据持久化,保证前端用户体验 二:vue.js的核心思想 (一):数据驱动 ( ...

  6. Html中src、href的相对路径与绝对路径

    What is a path? Why is this something developers should care about? A path is simply the location of ...

  7. Linux如何关闭防火墙和查看防火墙的具体情况

    1.Linux下关闭和开启防火墙 1) 重启后生效 开启: chkconfig iptables on 关闭: chkconfig iptables off 2) 即时生效,重启后失效 开启: ser ...

  8. 一行代码实现iOS序列化与反序列化(runtime)

    一.变量声明 为便于下文讨论,提前创建父类Biology以及子类Person: Biology: @interface Biology : NSObject { NSInteger *_hairCou ...

  9. Android Xutils 框架

    XUtils是git上比较活跃 功能比较完善的一个框架,是基于afinal开发的,比afinal稳定性提高了不少,下面是介绍: 鉴于大家的热情,我又写了一篇Android 最火框架XUtils之注解机 ...

  10. HUD 2444 The Accomodation of Students (二分图染色+最大匹配)

    #include<iostream> #include<cstdio> #include<cstring> #define maxn 2010 using name ...