zoukankan      html  css  js  c++  java
  • hdu1042

    N!

    Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 39265    Accepted Submission(s): 10930

    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
     
    Author
    JGShining(极光炫影)
     
     
     
     
     
     
     
    1. #include<iostream>
    2. using namespace std;
    3. #define MAX 100000
    4. int main()
    5. {
    6.  int i,j,count,n,l,temp;
    7.  int a[MAX];
    8.  while(scanf("%d",&n)!=EOF)
    9.  {
    10.   a[0]=1;
    11.   count=1;
    12.   for(i=1;i<=n;i++)
    13.   {
    14.    l=0;
    15.    for(j=0;j<count;j++)
    16.    {
    17.     temp=a[j]*i+l;
    18.     a[j]=temp%10;
    19.     l=temp/10;
    20.    }
    21.    while(l)
    22.    {
    23.     a[count++]=l%10;
    24.     l/=10;
    25.    }
    26.   }
    27.   for(j=100000;j>0;j--)
    28.    if(a[j])
    29.     break;
    30.    for(i=count-1;i>=0;i--)
    31.     printf("%d",a[i]);
    32.    printf("\n");
    33.  }
    34.  return 0;
    35. }
     
     
     
     
  • 相关阅读:
    Pandas 基础(8)
    Pandas 基础(7)
    Pandas 基础(6)
    Pandas 基础(5)
    Pandas 基础(4)
    python matplotlib 图表局部放大
    python 带小数点时间格式化
    emacs elpy代码补全功能
    spacemacs 初始安装报错
    视频加载logo 2
  • 原文地址:https://www.cnblogs.com/Deng1185246160/p/2951155.html
Copyright © 2011-2022 走看看