Ask for a factorial of 10000 or less n

Source: Internet
Author: User

Total time limit:
5000ms
Memory Limit:
655360kB
Describe

Ask for a factorial of 10000 or less n.

Input
Only one line of input, integer n (0<=n<=10000).
Output
A row, which is the value of n!.
Sample input
100
Sample output
9332621544394415268169923885626670049071596826438162146859296389521759999322991560894146397615651828625369792082722375825 1185210916864000000000000000000000000
Source
JP06

The code is actually:

1#include <cstdio>2 intn,a,fz[50000],ans[50000]={1,1};3 intMain () {4scanf"%d",&n);5      for(intI=1; i<=n;i++)6      for(intj=1; j<=ans[0];j++){7ans[j]=ans[j]*i+fz[j];fz[j]=0;8         if(ans[j]>9){9fz[j+1]+=ans[j]/Ten;Tenans[j]%=Ten; One             if(j==ans[0]) ++ans[0]; A         } -     } -      for(inti=ans[0];i>0; i--) printf ("%d", Ans[i]); theprintf"\ n"); -     return 0; -}

。。。

Ask for a factorial of 10000 or less n

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.