Nine degrees OJ topic 1051: Digital Ladder summation

Source: Internet
Author: User

Title Description:

Given A and n, computes the A+AA+AAA+A...A (n a).

Input:

There are several groups of test data, input a,n (1<=a<=9,1<=n<=100).

Output:

For each set of inputs, output the results.

Sample input:
1 10
Sample output:
1234567900

The difficulty of this problem is to deal with a long, long number of sums
1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <string>5#include <cmath>6 #defineMAX 3027 8 intSum[max];9 intTemp[max];Ten  One voidcalsum () { A     intCI =0; -     for(inti =0; I < max;i++) { -         intBen = (Sum[i] + temp[i] + ci)%Ten; theCI = (Sum[i] + temp[i] + ci)/Ten; -Sum[i] =ben; -    }  - } + intMainintargcChar Const*argv[]) - { +     inta, n; A      while(SCANF ("%d%d", &a,&n)! =EOF) { at          for(inti =0; i < MAX; i++) { -Sum[i] =0; -         } -          for(inti =1; I <= N; i++) { -              for(intj =0; J < MAX; J + +) { -TEMP[J] =0; in             } -              for(intj =0; J < I; J + +) { toTEMP[J] =A; +             } - calsum (); the         } *         BOOLIsbegin =false; $          for(inti = MAX; I >=0; i--) {Panax Notoginseng             if(Isbegin = =false&& Sum[i]! =0) { -Isbegin =true; theprintf"%d", Sum[i]); +             } A             Else if(isbegin) { theprintf"%d", Sum[i]); +             } -         } $printf"\ n"); $     } -     return 0; -}



Nine degrees OJ topic 1051: Digital Ladder summation

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.