HDU 1042 N!
来源:互联网 发布:大字体软件老人 编辑:程序博客网 时间:2024/05/16 20:28
N!
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
大数阶乘!!
#include <iostream>using namespace std;int a[55555];int main(){int n,i,j;while(scanf("%d",&n)!=EOF){memset(a,0,sizeof(a));if(n==0||n==1){printf("1\n");continue;}int l=1;a[0]=1;for(i=2;i<=n;i++){for(j=0;j<l;j++)a[j]*=i;for(j=0;j<l;j++){if(a[j]>9){a[j+1]+=a[j]/10;a[j]%=10;if(j==l-1)l++;}}}for(i=l-1;i>=0;i--)printf("%d",a[i]);printf("\n");}return 0;}
- N! ---HDU 1042
- HDU 1042 N!
- hdu 1042 N!
- HDU 1042 N!
- HDU 1042 N!
- hdu 1042 N!
- hdu 1042 N!
- HDU 1042 - N!
- hdu 1042 N!
- hdu 1042 N!
- HDU 1042 N!
- hdu 1042 N!
- HDU 1042 N!
- HDU 1042 N!
- Hdu 1042 - N!
- hdu 1042 N!
- hdu 1042 N!
- hdu 1042 N!
- iOS: NSDictionary的方法allKeysForObject:
- Tomcat布署WEB应用两种方式的区别
- ihaonet微趣味测试将以平均每天1个应用增加
- HDU 1853 Cyclic Tour 费用流(圈)
- Android开发优化之——对Bitmap的内存优化(转载)
- HDU 1042 N!
- iOS: NSDictionary的方法allValues
- Android手机安装原版BT5[ARM]
- C# Socket的粘包处理
- iOS: NSDictionary的方法count
- mongodb slow query analyzer
- HDU 2546 饭卡 【隐藏的背包问题】
- hdu - 4639 - Hehe(斐波那契数)
- iOS: NSDictionary的方法description