acm--large number factorial--hdoj 1042--n!--Java

Source: Internet
Author: User


Hdoj Title Address: Portal



N!Time limit:10000/5000 MS (java/others) Memory limit:262144/262144 K (java/others)Total Submission (s): 74952 Accepted Submission (s): 21832

Problem Descriptiongiven an integer n (0≤n≤10000), your task is to calculate N!

Inputone N in one line, process to the end of file.

Outputfor each n, output N! In one line.

Sample Input
123

Sample Output
126



Import Java.math.bigdecimal;import Java.math.biginteger;import Java.util.scanner;public class Main {public   static void Main (string[] args) {   Scanner cin = new Scanner (system.in);         while (Cin.hasnext ()) {       int n=cin.nextint ();       BigDecimal big=new BigDecimal (1);       for (int i=1;i<=n;i++) {       BigDecimal b= new BigDecimal (i);       Big=big.multiply (b);       }       System.out.println (big);}}}         


acm--large number factorial--hdoj 1042--n!--Java

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.