Nine degree OJ 1083 special multiplication (analog)

Source: Internet
Author: User

Topic 1083: Special multiplication

time limit:1 seconds

Memory limit:32 MB

Special question: No

submitted:2910

Resolution:2027

Title Description:

Write an algorithm that evaluates to 2 inputs that are less than 1000000000.

Special Multiplication Example: 123 * 45 = 1*4 +1*5 +2*4 +2*5 +3*4+3*5

Input:

Two a number less than 1000000000

Output:

Input may have more than one set of data, for each set of data, the output of two numbers in input according to the methods required by the method to calculate the results obtained.

Sample input:
123 45
Sample output:
54
Simple simulation

#include <stdio.h>long long a,b;int x[20];int y[20];void solve () {    int i=0;    int j=0;    int xn=0;    int yn=0;    while (a)    {        x[i++]=a%10;        a/=10;    }    xn=i;    i=0;    while (b)    {        y[i++]=b%10;        b/=10;    }    yn=i;    Long long sum=0;    for (I=0;i<xn;++i) for        (j=0;j<yn;++j)        {            sum+=x[i]*y[j];        }    printf ("%lld\n", sum);} int main (int argc, char *argv[]) {//   freopen ("1083.in", "R", stdin);    while (~scanf ("%lld%lld", &a,&b))    {        solve ();    }    return 0;} /**************************************************************    problem:1083    user:kirchhoff    Language:c    result:accepted    time:0 ms    memory:912 kb*********************************************** *****************/



Nine degree OJ 1083 special multiplication (analog)

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.