hdu1042 N!(高精度水过)
来源:互联网 发布:手机网络ip地址查询 编辑:程序博客网 时间:2024/05/17 22:38
N!
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 76906 Accepted Submission(s): 22482
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
123
Sample Output
126
熟悉了下高精度模板,水过。
但我是数组每一位存一个数,每个位置存4位还不太熟练= =
高精度水过代码:
#include<cstdio>#include<cstdlib>#include<iostream>#include<stack>#include<queue>#include<algorithm>#include<string>#include<cstring>#include<cmath>#include<vector>#include<map>#include<set>#define eps 1e-8#define zero(x) (((x>0?(x):-(x))-eps)#define mem(a,b) memset(a,b,sizeof(a))#define memmax(a) memset(a,0x3f,sizeof(a))#define pfn printf("\n")#define ll __int64#define ull unsigned long long#define sf(a) scanf("%d",&a)#define sf64(a) scanf("%I64d",&a)#define sf264(a,b) scanf("%I64d%I64d",&a,&b)#define sf364(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c)#define sf2(a,b) scanf("%d%d",&a,&b)#define sf3(a,b,c) scanf("%d%d%d",&a,&b,&c)#define sf4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)#define sff(a) scanf("%f",&a)#define sfs(a) scanf("%s",a)#define sfs2(a,b) scanf("%s%s",a,b)#define sfs3(a,b,c) scanf("%s%s%s",a,b,c)#define sfd(a) scanf("%lf",&a)#define sfd2(a,b) scanf("%lf%lf",&a,&b)#define sfd3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)#define sfd4(a,b,c,d) scanf("%lf%lf%lf%lf",&a,&b,&c,&d)#define sfc(a) scanf("%c",&a)#define ull unsigned long long#define debug printf("***\n")const double PI = acos(-1.0);const double e = exp(1.0);const int INF = 2<<20;template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }template<class T> inline T Min(T a, T b) { return a < b ? a : b; }template<class T> inline T Max(T a, T b) { return a > b ? a : b; }bool cmpbig(int a, int b){ return a>b; }bool cmpsmall(int a, int b){ return a<b; }using namespace std;#define MAX 50010int num[MAX];int main(){ //freopen("data.in","r",stdin); int n; while(~sf(n)) { mem(num,0); num[0]=1,num[1]=1; for(int i=1;i<=n;i++) { int len=num[0]; for(int j=1;j<=len;j++) num[j]*=i; for(int j=1;j<=num[0];j++) { if(num[j]>=10) { num[j+1]+=num[j]/10; num[j]%=10; } if(num[num[0]+1]) num[0]++; } } for(int i=num[0];i>=1;i--) printf("%d",num[i]); pfn; } return 0;}
0 0
- hdu1042 N!(高精度水过)
- hdu1042 N! (高精度\大数阶乘)
- HDU1042 N! 高精度:计算n!精确值
- 高精度乘以单精度 hdu1042 N!
- HDU1042(N!)
- hdu1042 (模拟n!)
- HDU1042 N!(java)
- HDU1042 N! (大精度)
- HDU1042 - N! (大数运算)
- 【学习笔记】hdu1042(高精度乘法)
- HDU1042 N!
- hdu1042 N!
- N! hdu1042
- hdu1042 N!
- HDU1042--N!
- hdu1042 N!
- HDU1042 N!
- N! HDU1042
- 一个通过smtp发送邮件的shell,带用户名密码
- JavaScript之工厂模式
- 严重: Error configuring application listener of class org.springframework.web.context.ContextLoaderLis
- NOIP模拟题[贪心][离散化][LIS]
- 洛谷 P1131 [ZJOI2007]时态同步
- hdu1042 N!(高精度水过)
- mysql遇到奇怪的问题
- [NOIP模拟][费马小定理][高精度]
- 1619-7 张良 十一月六号总结 [连续第三十七天]
- silverlight连接SQLite数据库,增删改查
- redis配置注意事项
- Jbpm通知custom
- VR学习第十一节:VR+汽车工业 VR+航空航天 VR+新闻 VR+广告
- 正式使用opencv里的训练和检测 - opencv_createsamples、opencv_traincascade-2.4.11版本