/*
N!
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 67077 Accepted Submission(s): 19228 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 Author
JGShining(极光炫影) Recommend
We have carefully selected several similar problems for you: 1715 1063 1753 1316 1013
*/
#include <iostream>
#include<stdio.h>
using namespace std;
const int Len = ;
int *a =new int[Len];
int main()
{
int i,j,n,pos,over;
//double test;
while(scanf("%d",&n)!=EOF)
{
//test=1;
pos=;
a[]=;
for(i=; i<=n; i++)
{
over=;
for(j=; j<=pos; j++)
{
a[j]*=i;
a[j]+=over;
over=a[j]/;//each five bit calculate
a[j]%=;
}
if(over!=)
{
pos+=;
a[pos]=over;
}
}
printf("%d",a[pos]);//high-five-bit output-length follow its length
for(i=pos-; i>=; i--)
{
printf("%05d",a[i]);//others output-length must be five
}
printf("\n");
//for(i=1;i<=n;i++)
//test*=i;
//printf("%f\n",test);
}
return ;
}

hdu1042 N!的更多相关文章

  1. HDU1042(N!)题解

    HDU1042(N!)题解 以防万一,题目原文和链接均附在文末.那么先是题目分析: [一句话题意] 计算N的阶乘并输出. [题目分析] 题给范围上限是10000,那么毫无疑问是大数题.之前我整理过各种 ...

  2. HDU-1042 N!

    首先明白这是大数问题,大数问题大多采用数组来实现.如何进位.求余等.比如1047 (Integer Inquiry): 对于1042问题 计算10000以内数的阶乘,因为10000的阶乘达到35660 ...

  3. 杭电HDU1042(有点坑的高精度)

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题意: Given an integer N(0 ≤ N ≤ 10000), your task i ...

  4. HDU1042 N! 大数的阶乘

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 由于数字特别大, 所以用数组来模拟. 经测试, 数组大小开50000 可过. 附AC代码, 欢迎 ...

  5. hdu1042(大数模板)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 在网上找了个大数模板方便以后用得到. #include<iostream> #inc ...

  6. hdu1042

    #include"stdio.h" #include"stdlib.h" #include"string.h" #define N 1000 ...

  7. 用Java进行大数处理(BigInteger)-hdu1042

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目描述: 代码实现: import java.util.Scanner; import jav ...

  8. (大数 万进制) N! hdu1042

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

  9. HDU-1042.N!(大数与小数相乘的乘法模拟)

    本题大意:给定一个10000以内的整数n,让你求出n!并输出. 本题思路:先初始化一个存放答案的数组ans,初始ans[0] = 1,并初始化其剩下的元素为0,接着就从2开始依次与ans数组内的每一个 ...

随机推荐

  1. 重新想象 Windows 8 Store Apps (65) - 后台任务: 音乐的后台播放和控制

    [源码下载] 重新想象 Windows 8 Store Apps (65) - 后台任务: 音乐的后台播放和控制 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 后台 ...

  2. sql 两列相加存到另一列

    假设表table1有a.b两个列,想生成另一个列为a列值+b列值计算列添加语句如下ALTER TABLE table1ADD c AS a+b

  3. ahjesus 让Boot Camp支持创建win7 u盘安装盘

    通过修改BootCamp助理成功创建USB的windows7的安装盘. 以下将方法共享出来. 准备工作: 找到自己电脑的Boot Rom 版本.(点左上角那个小苹果标志 然后点 [关于本机] 然后点 ...

  4. 设置让ASP.NET管道接收所有类型的请求

    在web.config文件添加如下一段配置: <configuration> <system.webServer> <modules runAllManagedModul ...

  5. mysql存储过程性能监控和分析

    公司当前版本的系统大量的使用了存储过程,有些复杂的过程套过程,一个主调用者可能最多调用其它几十个小的业务逻辑和判断,不要说这么做很不合理,在大陆,目前至少30%的证券交易系统代码都是用存储过程写业务逻 ...

  6. 编写运行R脚本

    1.在后台运行R 1.1 创建file.R文件 1.2 在文件首行键入: #! /path/to/Rscript 1.3 在下面的行中,键入R代码 1.4 保存(记得有png(),jpeg(),... ...

  7. [Android] 环境配置之基础开发环境(SDK/Android Studio)(转)

    [Android] 环境配置之基础开发环境(SDK/Android Studio)   博客: blog.csdn.net/qiujuer 网站: www.qiujuer.net 开源库: Geniu ...

  8. 【GOF23设计模式】中介者模式

    来源:http://www.bjsxt.com/ 一.[GOF23设计模式]_中介者模式.同事协作类.内部类实现 package com.test.mediator; /** * 同事类的接口 */ ...

  9. 初学Node(五)文件I/O

    文件读写 Node的出现的一个亮点就是让JS也有了读写文件的能力,而且实现起来要比其他语言更简单,对文件的一些操作我们都可通过fs模块来完成.fs即fileSystem的缩写,fs模块可以完成对文件的 ...

  10. miniSipServer简单而不简单,轻松落地,实现电脑对固话、手机通讯

    最近沉迷于SIP通讯,网内通讯全免费,落地也就几分钱,而且无漫游全国拨打,想想真是心动呢,只要有网落就ok!. 对于sipserver,现在的市场上软件很多,免费的.收费的应有尽有,这里不一一例举.综 ...