Description

求N!

\(N \leq 1000\)

Sample Input

10

30

50

100

Sample Output

10!

3628800

30!

265252859812191058636308480000000

50!

30414093201713378043612608166064768844377641568960512000000000000

100!

93326215443944152681699238856266700490715968264381621468592963895217599993229915

608941463976156518286253697920827223758251185210916864000000000000000000000000

Solution

简单高精即可

Code

#include <cstdio>
#include <cstring>
using namespace std; const int mod=1e5;
int n,f[1010],len; int main(){
while(~scanf("%d",&n)){
f[1]=1;
len=1;
for(int i=2;i<=n;++i){
int pd=0;
for(int j=1;j<=len;++j){
int tmp=f[j]*i+pd;
pd=tmp/mod;
f[j]=tmp%mod;
}
if(pd>0) f[++len]=pd;
}
printf("%d!\n",n);
printf("%d",f[len]);
for(int i=len-1;i;i--)
printf("%05d",f[i]);
printf("\n");
}
return 0;
}

[Uva623]500!(高精)的更多相关文章

  1. 【Uva623】500!(高精)

    Description 求N! \(N \leq 1000\) Sample Input 10 30 50 100 Sample Output 10! 3628800 30! 265252859812 ...

  2. 题解 P1601 【A+B Problem(高精)】

    P1601 A+B Problem(高精) 题目描述 高精度加法,x相当于a+b problem,b不用考虑负数. 输入输出格式 输入格式: 分两行输入a,b<=10^500 输出格式: 输出只 ...

  3. 【洛谷P1601 A+B Problem(高精)】

    题目背景 无 题目描述 高精度加法,x相当于a+b problem,[b][color=red]不用考虑负数[/color][/b] 输入输出格式 输入格式: 分两行输入a,b<=10^500 ...

  4. 洛谷1601 A+B Problem(高精) 解题报告

    洛谷1601 A+B Problem(高精) 本题地址:http://www.luogu.org/problem/show?pid=1601 题目背景 无 题目描述 高精度加法,x相当于a+b pro ...

  5. 洛谷 P1601 A+B Problem(高精)

    P1601 A+B Problem(高精) 题目背景 无 题目描述 高精度加法,x相当于a+b problem,[b][color=red]不用考虑负数[/color][/b] 输入输出格式 输入格式 ...

  6. Linux 高精確的時序(sleep, usleep,nanosleep) from:http://blog.sina.com.cn/s/blog_533ab41c0100htae.html

    Linux 高精確的時序(sleep, usleep,nanosleep) (2010-04-14 17:18:26) 转载▼ 标签: 杂谈 分类: linux 首先, 我会说不保证你在使用者模式 ( ...

  7. c++ 普通高精除高精

    //codevs3118 高精度练习之除法 //打出了高精除高精,内心有点小激动. //还记得已开始学的时候非常难打 #include<cstdio>#include<cstring ...

  8. c++普通高精加

    //作为一名蒟蒻,还请诸位不要吐槽. //第一次打c++高精加,内心有点小激动. //为codevs3116 高精度练习之加法 //程序太简单,就不打注释了. #include<cstdio&g ...

  9. BZOJ_1002_[FJOI2007]_轮状病毒_(递推+高精)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1002 )*&*(^&*^&*^**()*) 1002: [FJOI20 ...

随机推荐

  1. Golang: runnerw.exe: CreateProcess failed with error 216 (no message available)

    话说这个我应该遇到几次了 每次新项目都有这问题,我的记忆是金鱼的记忆吗? 好在这次隐约记起是包名的问题... 方法 修改包名为main

  2. 华为云kafka POC 踩坑记录

    2019/03/08 18:29 最近在进行华为云相关POC验证,个人主要负责华为云DMS kafka相关.大致数据流程是,从DIS取出数据,进行解析处理,然后放入kafka,再从kafka中取出数据 ...

  3. css3的transform变换scale和translate等影响jQuery的position().top和offset().top

    css3的transform变换scale和translate等影响jQuery的position().top和offset().top

  4. vue-extend 选项

    vue-extend 选项 mixins 和extend 很相似,但有区别: var extendNews={ //后来的内容用变量接收 updated:function(){ console.log ...

  5. Notification高级技巧

    观察Notification这个类,你会发现里面还有很多我们没有使用过的属性.先来看看sound这个属性吧,它可以在通知发出的时候播放一段音频,这样就能够更好地告知用户有通知到来.sound 这个属性 ...

  6. 「转」sqlalchemy 0.9.8 多对多级联删除

    转自知乎 http://www.zhihu.com/question/21050551 有 A,B,C,AB,AC五张表 class A(base): __tablename__ = "a& ...

  7. centos6.5_64bit安装Redis3.2.8

    一.去官网下载最新稳定版 https://redis.io/   二.打开redis需要的端口 /sbin/iptables -I INPUT -p tcp --dport 6379 -j ACCEP ...

  8. shell 快速浏览

    总结自: https://github.com/qinjx/30min_guides/blob/master/shell.md: http://blog.itpub.net/14293828/view ...

  9. 一些好的IOS blog 不断增加中。。。。

    http://www.swiftkiller.com/?p=371 http://blog.csdn.net/javayujiafeng/article/details/14163319 http:/ ...

  10. 从暴力匹配到KMP算法

    前言 现在有两个字符串:\(s1\)和\(s2\),现在要你输出\(s2\)在\(s1\)当中每一次出现的位置,你会怎么做? 暴力匹配算法 基本思路 用两个指针分别指向当前匹配到的位置,并对当前状态进 ...