设为首页 - 加入收藏 PHP编程网 - PHP站长网 (http://www.52php.cn)- 电商,百科,编程,业界,移动互联,5G,云计算,站长网!
热搜: 娱乐 站长之家 服务 百度
当前位置: 首页 > 大数据 > 正文

HDU 1042 大数

发布时间:2021-01-24 05:16 所属栏目:[大数据] 来源:网络整理
导读:N! Time Limit: 10000/5000 MS (Java/Others)????Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 74633????Accepted Submission(s): 21696 Problem Description Given an integer N(0 ≤ N ≤ 10000),your task is to calculate N! ?

N!

Time Limit: 10000/5000 MS (Java/Others)????Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 74633????Accepted Submission(s): 21696


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

http://www.cnblogs.com/Su-Blog/archive/2012/08/27/2659172.html 转载

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

// 又做一道大数

// POJ 2389 两个大数相乘 转载的方法不行

// 必须的拆开 比如888*88 = 8*8+8*8*10+8*8*100+8*8*10+8*8*10*10+8*8*10*100;

//用字符串储存*10就不一0 ;

<pre name="code" class="cpp">#include<iostream>
#define MAX 100000
using namespace std;
int main()
{
    int n,a[MAX];
    int i,j,k,count,temp;
    while(cin>>n)
    {
        a[0]=1;
        count=1;
        for(i=1;i<=n;i++)
        {
            k=0;
            for(j=0;j<count;j++)
            {
                temp=a[j]*i+k;        //如果i过大就不行;
                a[j]=temp%10;
                k=temp/10;
            }
            while(k)//记录进位
             {
                a[count++]=k%10;
                k/=10;
            }
        }
        //for(j=MAX-1;j>=0;j--)
            //if(a[j])
             //   break;//忽略前导0
            for(i=count-1;i>=0;i--)
                cout<<a[i];
            cout<<endl;
    }
    return 0;
}

   
   
// JAVA大数

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			BigInteger a = sc.nextBigInteger();
			BigInteger b = sc.nextBigInteger();
			System.out.println(a.multiply(b));
		}
	}

}
// 大数用java 没办法谁叫别人JAVA比较高级 别人封装好了的 去记单词吧

【免责声明】本站内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。

推荐文章
热点阅读