hdu 1042

高精度大数运算其实就是由于数字过大必须要用数组来存数据

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1020

#include<stdio.h>
#include<math.h>
#include<iterator>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;

int main()
{ 
	int a[100005],i,j,num,count,k;
	while(scanf("%d",&num)!=EOF)
	{
		a[0]=1;
		count=1;
		
		for(i=1;i<=num;i++)
		{
			k=0;
			for(j=0;j<count;j++)
			{
				int temp=a[j]*i+k;
				a[j]=temp%10;
				k=temp/10;
			}
			while(k)
			{
				a[count++]=k%10;//在上边的基础上进行拓展位数 
				k/=10;
			}
		}
		for(i=count-1;i>=0;i--)
			cout<<a[i];
		cout<<endl;
		
	}
	return 0;
}

  

posted @ 2015-08-31 23:11  澧浦  阅读(121)  评论(0)    收藏  举报