HDU1042 N!(大整数类应用)
来源:互联网 发布:生物技术专业 知乎 编辑:程序博客网 时间:2024/06/08 19:43
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
Code:
#include <iostream>#include <algorithm>#include <stdio.h>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <ctype.h>using namespace std;int a[50000];int main(){ int n; while(scanf("%d",&n)!=EOF) { int i,j,carry,len=1,t; memset(a,0,sizeof(a)); a[0]=1; for(i=2;i<=n;i++) { for(carry=0,j=0;j<len;j++) { t=a[j]*i+carry; a[j]=t%10; carry=t/10; } while(carry) { a[j++]=carry%10; carry/=10; len++; } } for(j=len-1;j>=0;j--) printf("%d",a[j]); printf("\n"); } return 0;}
阅读全文
0 0
- HDU1042 N!(大整数类应用)
- hdu1042 n! 大整数阶乘
- hdu1042——实现大整数N!
- HDU1042 N! (大精度)
- 求大整数的阶乘(hdu1042)
- HDU1042 N!
- hdu1042 N!
- N! hdu1042
- hdu1042 N!
- HDU1042--N!
- hdu1042 N!
- HDU1042 N!
- N! HDU1042
- HDU1042---N!
- hdu1042 N!
- HDU1042 N!
- hdu1042 N!
- HDU1042 n!
- HDU1036 Average is not Fast Enough!
- shiro(四) 关于session:验证登录时候如何处理session以及其他
- HDU1039 Easier Done Than Said?
- .NET Core 2.0 正式发布信息汇总
- Java并发信号量demo
- HDU1042 N!(大整数类应用)
- How to disable “Type <return> to continue, or q <return> to quit” in gdb?
- pop_count操作
- UVA 202
- HDU1047 Integer Inquiry
- linux测试服务器如何部署web项目
- 解决MySql登录错误ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
- HUD1048 The Hardest Problem Ever
- JavaEE开发之SpringMVC中的路由配置及参数传递详解