hdu1042 N!
/*
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!的更多相关文章
- HDU1042(N!)题解
HDU1042(N!)题解 以防万一,题目原文和链接均附在文末.那么先是题目分析: [一句话题意] 计算N的阶乘并输出. [题目分析] 题给范围上限是10000,那么毫无疑问是大数题.之前我整理过各种 ...
- HDU-1042 N!
首先明白这是大数问题,大数问题大多采用数组来实现.如何进位.求余等.比如1047 (Integer Inquiry): 对于1042问题 计算10000以内数的阶乘,因为10000的阶乘达到35660 ...
- 杭电HDU1042(有点坑的高精度)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题意: Given an integer N(0 ≤ N ≤ 10000), your task i ...
- HDU1042 N! 大数的阶乘
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 由于数字特别大, 所以用数组来模拟. 经测试, 数组大小开50000 可过. 附AC代码, 欢迎 ...
- hdu1042(大数模板)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 在网上找了个大数模板方便以后用得到. #include<iostream> #inc ...
- hdu1042
#include"stdio.h" #include"stdlib.h" #include"string.h" #define N 1000 ...
- 用Java进行大数处理(BigInteger)-hdu1042
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目描述: 代码实现: import java.util.Scanner; import jav ...
- (大数 万进制) N! hdu1042
N! Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Total Subm ...
- HDU-1042.N!(大数与小数相乘的乘法模拟)
本题大意:给定一个10000以内的整数n,让你求出n!并输出. 本题思路:先初始化一个存放答案的数组ans,初始ans[0] = 1,并初始化其剩下的元素为0,接着就从2开始依次与ans数组内的每一个 ...
随机推荐
- PUT 还是 POST ?
http://www.oschina.net/translate/put-or-post http://my.oschina.net/u/1263964/blog/268932 这两个方法咋一看都可以 ...
- edittext 监听内容变化
给EditText追加ChangedListener可以监听EditText内容变化的监听 如图是效果图 类似于过滤的一种实现 1 布局也就是一个EditText,当EditText内容发生变化时 ...
- STL---Codeforces675D Tree Construction(二叉树节点的父亲节点)
Description During the programming classes Vasya was assigned a difficult problem. However, he doesn ...
- Scala on Visual Studio Code
Download and install Scala Download a scala installation package from here. Then install it. Linux s ...
- bootstrap 弹出框点击其他区域时弹出框不消失选项设置
默认情况下,bootstrap 弹出框点击其他区域时,弹出框会自动关闭,在很多时候,我们可能会希望达到和原生弹出框一样的效果,避免不小心点击其他区域时弹框自动隐藏,尤其是对于一些复杂的表单,重复填写可 ...
- [ html canvas 模仿支付宝刮刮卡效果 ] canvas绘图属性 模仿支付宝刮刮卡效果实例演示
<!DOCTYPE html> <html lang='zh-cn'> <head> <title>Insert you title</title ...
- 安卓第六天笔记--ListView
安卓第六天笔记--ListView 1.AdapteView AdapteView 继承ViewGroup它的本质是容器 AdapterView派生了3个子类: AbsListView AbsSpin ...
- Android网络编程基础
Android网络编程只TCP通信 TCP 服务器端工作的主要步骤如下.步骤1 调用ServerSocket(int port)创建一个ServerSocket,并绑定到指定端口上.步骤2 调用acc ...
- iOS 自定义Actionsheet
自定义的Actionsheet效果如下 自定义的思路 1.在window上添加两个图层,背景层和功能层,如下图 2.设置背景层的背景色和透明度,并在背景层上添加点击事件 3.将自定义的view添加为功 ...
- XCode升级到7后,规范注释生成器VVDocumenter插件没有用了,怎么办?
Xcode更新到7之后,发现很多插件包括规范注释生成器VVDocumenter的插件都没法用了,找遍百度都没有找到成功解决这个问题的方法,然后我突发奇想,把注释也弄进代码模板里.虽然没有插件那样灵活: ...