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数组内的每一个 ...
随机推荐
- 浅谈ImageList
ImageList组件用了很久,但是一直不太清楚它的实现原理,今天专门特意花了时间倒腾了下,终于弄明白了!于是在这里和大家分享下! 在设计页面中打卡工具箱-组件 找到ImageList组件,将它直接拖 ...
- 重新想象 Windows 8 Store Apps (50) - 输入: 边缘手势, 手势操作, 手势识别
[源码下载] 重新想象 Windows 8 Store Apps (50) - 输入: 边缘手势, 手势操作, 手势识别 作者:webabcd 介绍重新想象 Windows 8 Store Apps ...
- Python轻量Web框架Flask使用
http://blog.csdn.net/jacman/article/details/49098819 目录(?)[+] Flask安装 Python开发工具EclipsePyDev准备 Flask ...
- [moka同学代码]PHP初级知识:上传文件源码
1.目录结构
- 中国快递包裹总量的预测-基于SARIMA模型
code{white-space: pre;} pre:not([class]) { background-color: white; }if (window.hljs && docu ...
- Windows程序控件升级==>>构建布局良好的Windows程序
01.菜单栏(MenuStrip) 01.看看这就是menuStrip的魅力: 02.除了一些常用的属性(name.text..)外还有: 03.有人会问:上图的快捷键: 方法: 方式一:1.设置菜单 ...
- IFeatureCursor.Flush
IFeatureCursor.Flush Method Flush any outstanding buffered writes to the database. [Visual Basic .NE ...
- MVC中的CSRF解决方案
我们使用Ajax访问请求的时候,攻击者可能盗用了用户身份,以用户合法身份发送恶意请求. 具体预防措施, 1.在Html表单里面使用@Html.AntiForgeryToken(),这玩意会生成一对加密 ...
- Force.com微信开发系列(一) 后台配置
为寻找国内免费云资源作为微信后台,花了一天时间试用SinaAppEngine(SAE),调试太不方便用户体验差.新浪作为媒体公司技术功底经不起考验,亚马逊能推出AWS,新浪还不行!更好选项是百度Bai ...
- iOS didReceiveMemoryWarning 的处理
当iOS触发didReceiveMemoryWarning这个方法的时候,我们一般会做一些手动处理,强制清理掉一些目前不用的数据.但是这个方法并不只是单纯的通知开发者你的内存已经吃紧了,系统通知你的同 ...