Cow Multiplication
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 13312   Accepted: 9307

Description

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.

Input

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

Output

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

Sample Input

123 45

Sample Output

54

Source

分析:算是处理字符串吧!用两个数组去做,用一个数去计算它们的和即可!
下面给出AC代码:
 #include <algorithm>
#include <cstring>
#include <cstdio>
#include <iostream>
using namespace std;
int main()
{
char a[],b[];
int c[];
while(scanf("%s%s",&a,&b)!=EOF)
{
memset(c,,sizeof(c));
int s=;
int lena=strlen(a);
int lenb=strlen(b);
for(int i=;i<lena;i++)
{
for(int j=;j<lenb;j++)
{
c[i]=(int)(a[i]-'')*(int)(b[j]-'');
s+=c[i];
}
}
cout<<s<<endl;
}
return ;
}

POJ 3673 Cow Multiplication的更多相关文章

  1. POJ 3673 Cow Multiplication (水题)

    题意:给你两个数,求所有的数位的积的和. 析:太水了,没的说,可以先输入边算,也可以最后再算,一样.. 代码如下: #include <cstdio> #include <strin ...

  2. POJ 3673:Cow Multiplication

    Cow Multiplication Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12210   Accepted: 85 ...

  3. POJ 3045 Cow Acrobats (贪心)

    POJ 3045 Cow Acrobats 这是个贪心的题目,和网上的很多题解略有不同,我的贪心是从最下层开始,每次找到能使该层的牛的风险最小的方案, 记录风险值,上移一层,继续贪心. 最后从遍历每一 ...

  4. poj 3348 Cow 凸包面积

    Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8122   Accepted: 3674 Description ...

  5. POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包)

    POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包) Description N (1 ≤ N ...

  6. POJ 3176 Cow Bowling(dp)

    POJ 3176 Cow Bowling 题目简化即为从一个三角形数列的顶端沿对角线走到底端,所取得的和最大值 7 * 3 8 * 8 1 0 * 2 7 4 4 * 4 5 2 6 5 该走法即为最 ...

  7. POJ 2184 Cow Exhibition【01背包+负数(经典)】

    POJ-2184 [题意]: 有n头牛,每头牛有自己的聪明值和幽默值,选出几头牛使得选出牛的聪明值总和大于0.幽默值总和大于0,求聪明值和幽默值总和相加最大为多少. [分析]:变种的01背包,可以把幽 ...

  8. POJ 2375 Cow Ski Area(强连通)

    POJ 2375 Cow Ski Area id=2375" target="_blank" style="">题目链接 题意:给定一个滑雪场, ...

  9. Poj 3613 Cow Relays (图论)

    Poj 3613 Cow Relays (图论) 题目大意 给出一个无向图,T条边,给出N,S,E,求S到E经过N条边的最短路径长度 理论上讲就是给了有n条边限制的最短路 solution 最一开始想 ...

随机推荐

  1. python scipy计算机数值库

    scripy有聚类的python 代码,如: http://blog.csdn.net/elaine_bao/article/details/50242867

  2. 浅析c++和c语言的enum类型

    1.先看c语言枚举类型 1.c语言定义枚举类型,每一个枚举元素都是一个整数2.注重数据类型,没有数据类型限定3.相邻枚举元素相差整数4.可以通过整数访问,不够安全 2.上代码: 1 #include& ...

  3. Asp.net常用开发方法之DataTable/DataReader转Json格式代码

    public static string JsonParse(OleDbDataReader dataReader) //DataRead转json { StringBuilder jsonStrin ...

  4. Java8函数之旅 (五) -- Java8中的排序

    前言    对数据进行排序是平常经常会用到的操作之一,使用Jav8排序可以减少你在排序这方面的代码量,优化你的代码. 测试用例代码 定义个实体类User,拥有姓名name,年龄age,积分credit ...

  5. @NotEmpty、@NotBlank、@NotNull的区别

    @NotEmpty 用在集合类上面  @NotBlank 用在String上面  @NotNull 用在基本类型上 只有简单的结果,但是再更具体一点的内容就搜不到了,所以去看了看源码,发现了如下的注释 ...

  6. shell脚本异步日志分析-接口耗时、可用率

    背景:现有日志接入日志报表大盘,为了避免作业高峰期间(双十一),系统也要观测系统整体情况,因此提出了观测近五分钟,接口成功率以及耗时等工具(默认统计最近五分钟,并进行结果汇总统计) 使用说明 前提:p ...

  7. 一种优雅的条件引用第三方.net库的方法

    1.遇到的问题 今年我一直在开发一个WebApiClient库,旨在.net下能像java的retrofit一样,方便地请求服务端的http接口.在这restful api盛行的年代,json的身影无 ...

  8. Jenkins:VMware虚拟机Linux系统的详细安装和使用教程

    jenkins:VMware虚拟机Linux系统的详细安装和使用教程 (一) 不是windows安装虚拟机可跳过 1.Windows安装VMware 2.VMware安装linux系统 3.windo ...

  9. Dubbo(五) Dubbo入门demo——helloworld

    前言 前面我已经介绍了dubbo的一些基本工具和知识,让大家简单的了解了下RPC框架和Dubbo.接下来就是重点了,Dubbo的helloworld项目. 一.搭建项目 首先我们新建三个maven项目 ...

  10. mac上使用appium连接真机问题

    1.链接真机时一直报错 app is not install 日志如下: 解决办法:是因为lockdown挂了,在命令行输入sudo chmod -R 777 /var/db/lockdown/ 但是 ...