大数阶乘
来源:互联网 发布:bugfree windows 编辑:程序博客网 时间:2024/05/16 03:37
A - N!
Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription
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
数组模拟
我跑了一个10000的数据,显示超时根本算不出来,可提交竟然对了,10000!真是个天文数字。
#include<stdio.h>#include<string.h>int main(){int a[101000],n,l;while(~scanf("%d",&n)){memset(a,0,sizeof(a));a[0] =1;l=1;for(int i=1;i<=n;i++){int s = 0,j;for( j=0;j<l||s;j++){ int z= a[j]*i+s;a[j] = z%10;s = z/10;}l=j;//printf("%d\n",l);}for(int j = l-1;j>=0;j--)printf("%d",a[j]);printf("\n");}}
1 0
- 大数阶乘
- 大数阶乘。
- 大数阶乘
- ~阶乘~大数
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 大数阶乘!!
- 大数阶乘
- 大数阶乘
- 大数阶乘
- 示例1 ConnectNoEncryption
- safsafasfasfasfasf
- AndroidJNI 通过C++调用JAVA
- 多态,动态类型和动态绑定
- asfasfasfasfasfasf
- 大数阶乘
- qt 异常举例
- 示例2 ConnectWithWEP
- 54564564564556
- 关于stat函数和根据st_mode 的值获取目标文件的文件类型和用户权限,及对相关系统宏的一点想法
- 字符串匹配的Boyer-Moore算法
- 游戏运营学习笔记六 试玩网易手游 《迷你西游》 体验报告
- 用流对象的成员函数控制输出数据格式
- asfsafasfasfasf