Array multiplication (large integer multiplication)

Source: Internet
Author: User

Title: Power of Cryptography

Solution: 8263971

Topic type: Divide and conquer (probably, not very sure)

Knowledge Point: Pow () function of the underlying operation mechanism (because this problem incredibly can use a function on AC off!!?? ), the number of digits of the determination, the array phase multiplication (that is, the multiplication of two super-large integers, can only be stored with an array), two-point lookup method (save time, after all, the topic gives time only 1 seconds!) )

Title: Niu class online https://www.nowcoder.com/acm/contest/75#question Attack! Factorial

Solution:

#include <stdio.h>//array multiplication, res_size: Indicates how many bits, the number of bits returned by the resultintMultiplyintXintRes[],intres_size) {    intcarry =0;//Rounding     for(intI=0; i<res_size; i++) {        intPROD = res[i] * x +carry; Res[i]= prod%Ten; Carry= prod/Ten; printf ("carry =%d\n", carry); }     while(carry!=0) {Res[res_size]= carry%Ten; Carry= carry/Ten; Res_size++; } printf ("res_size =%d\n", res_size); returnres_size;}voidFactorial (intN) {intres[36000];//10000! number of digits not exceeding 36000//Initializeres[0] =1; intRes_size =1;//indicates how many bits are//Calculate n!     for(intx=2; x<=n; X + +) {res_size=Multiply (x, res, res_size); }     for(inti=res_size-1; i>=0; i--) {printf ("%d", Res[i]); } printf ("\ n");}intMain () {Long LongN;  while(SCANF ("%lld", &n)! =EOF)    {factorial (N); }    return 0;}

Topic Knowledge Points: Array multiplication

Array multiplication (large integer multiplication)

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.