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)