Cow Multiplication

桃扇骨 2022-08-10 08:40 239阅读 0赞

Cow Multiplication

Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^

题目描述

Bessie is tired of multiplying pairs of numbers the usual way, so she invented her own style of multiplication. In her style, A*B is equal to the sum of all possible pairwise products between the digits of A and B. For example, the product 123*45 is equal to 1*4 + 1*5 + 2*4 + 2*5 + 3*4 + 3*5 = 54. Given two integers A and B (1 ≤ A, B ≤ 1,000,000,000), determine A*B in Bessie\‘s style of multiplication.

输入

* Line 1: Two space-separated integers: A and B .

输出

* Line 1: A single line that is the A*B in Bessie\‘s style of multiplication.

示例输入

  1. 123 45

示例输出

  1. 54

提示

来源

示例程序

  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. int i,j,n,m,k=0,t;
  6. char a[100],b[100];
  7. scanf("%s %s",a,b);
  8. n=strlen(a);
  9. m=strlen(b);
  10. for(i=0;i<n;i++)
  11. for(j=0;j<m;j++)
  12. k+=(a[i]-'0')*(b[j]-'0');
  13. printf("%d\n",k);
  14. }

发表评论

表情:
评论列表 (有 0 条评论,239人围观)

还没有评论,来说两句吧...

相关阅读

    相关 Brown Cow模型

    业务用例对需求活动来说非常基础,不论项目类型和情况如何,都要考虑每次针对一个业务用例进行需求调研。 『Brown Cow模型』:   ![format_png][]  

    相关 Cow Gymnastics

    题目描述 为了提高健康水平,奶牛们开始进行体操训练了!Farmer John 选定了他最喜爱的奶牛 Bessie 来执教其他 N 头奶牛,同时评估她们学习不同的体操技术的

    相关 Catch That Cow

    think: 1广度优先搜索(队列思想) 2以结构数组为基础的队列思想 3反思:自己因为vis数组有的初始化位置不对,导致runtime error.??? hi