Sdut OJ 2059 Simple n! (A large number of algorithms multiplied by a decimal, a large number with a fractional division algorithm "template")

Source: Internet
Author: User

Simple n! Time limit:1000ms Memory limit:65536k have questions? Dot here ^_^ The title describes a given number n (0 <= n <= 150), which is the factorial of 0 to N. Input

The topic has multiple sets of data that are processed to the end of the file. Enter a number n.

Output

Output factorial, in the form of: 4! = 24. Each set of data is output followed by a blank line.

Sample input
14
Sample output
0! = 11! = 10! = 11! = 12! = 23! = 64! = 24
Hint Code:
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm> #include < iostream> #include <iomanip> #include <cctype> #include <string>using namespace std;//implementation 1->    150 factorial int main () {int r[601];int I, J, K, C;int t; int N;while (scanf ("%d", &n)!=eof) {if (n==0) {printf ("0!) = 1\n\n "); continue;} if (n==1) {printf ("0! = 1\n1!        = 1\n\n "); continue;} printf ("0! = 1\n1!            = 1\n "); for (i=0; i<=600; i++) {r[i]=0;}    R[0]=j=1;    For (i=2, i<=n; i++) {for (k=0; k<j; k++) {r[k]=r[k]*i;}    for (k=c=0; k<j; k++) {t=r[k]+c;    r[k]=t%10;    C=T/10;}    while (c) {r[j]=c%10;    C=C/10; j + +;}            The rounding problem that deals with that part of the high//printf ("%d---\ n", j); printf ("%d!    = ", i);    for (k=j-1; k>=0; k--) {printf ("%d", R[k]);} printf ("\ n");}   printf ("\ n");} return 0;} Division is not involved! Pending add/**************************************problem id:sdut OJ 2059 result:accepted take memory:496k take time:10ms Sub MIT time:2015-01-11 08:22:42 **************************************/ 

Sdut OJ 2059 Simple n! (A large number of algorithms multiplied by a decimal, a large number with a fractional division algorithm "template")

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.