The large number factorial of Nanyang oj-

Source: Internet
Author: User

This question will not, level too, the ability to convert the problem into a program is too weak, do not know which aspects are insufficient.

The best code for direct copy:

#include<iostream>#include<iomanip>using namespacestd;//to store factorial within 20000inta[15470]; Use arrays to store results, one five-digit number per elementintMain () {    intN; CIN>>N; a[1]=1; a[0]=1; This a[0] is a counter that records the number of five digitsintUp ; Forward a five-digit number of rounding for(intI=2; i<=n;++i)//multiplier from 2 to n {up=0; Multiply by each multiplier and return to zero for(intj=1; j<=a[0];++J)//existing numeric digits participate in the operation{A[j]*=i; Multiply each five-digit number by multiplier A[j]+=Up ; Plus rounding up=a[j]/100000; Calculate the next carry A[j]%=100000; The value of the current five-digit number}if(up!=0) {a[0]++; If there is carry, the counter plus a a[a[0]]=Up ; Hold Carry}}if(a[0]==1) cout<<a[1]; Else{cout<<a[a[0]];  for(inti=a[0]-1;i>0; i--) {cout<<setfill ('0') &LT;&LT;SETW (5) <<A[i]; Top five-digit }}}

The large number factorial of Nanyang oj-

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.