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

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 andB. 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

还是水题。。。字符串按位乘,再相加。

代码:

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std; int main()
{
string m,n;
cin>>m>>n; int i,j,result=0;
for(i=0;i<m.length();i++)
{
for(j=0;j<n.length();j++)
{
result += (m[i]-'0')*(n[j]-'0');
}
}
cout<<result<<endl;
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

POJ 3673:Cow Multiplication的更多相关文章

  1. POJ 3318:Matrix Multiplication(随机算法)

    http://poj.org/problem?id=3318 题意:问A和B两个矩阵相乘能否等于C. 思路:题目明确说出(n^3)的算法不能过,但是通过各种常数优化还是能过的. 这里的随机算法指的是随 ...

  2. POJ 3176:Cow Bowling

    Cow Bowling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13464   Accepted: 8897 Desc ...

  3. POJ 2184:Cow Exhibition(01背包变形)

    题意:有n个奶牛,每个奶牛有一个smart值和一个fun值,可能为正也可能为负,要求选出n只奶牛使他们smart值的和s与fun值得和f都非负,且s+f值要求最大. 分析: 一道很好的背包DP题,我们 ...

  4. POJ 3673 Cow Multiplication

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

  5. POJ 3617 Best Cow Line(最佳奶牛队伍)

    POJ 3617 Best Cow Line Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] FJ is about to t ...

  6. POJ 3268 Silver Cow Party 最短路—dijkstra算法的优化。

    POJ 3268 Silver Cow Party Description One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbe ...

  7. Poj 3189 Steady Cow Assignment (多重匹配)

    题目链接: Poj 3189 Steady Cow Assignment 题目描述: 有n头奶牛,m个棚,每个奶牛对每个棚都有一个喜爱程度.当然啦,棚子也是有脾气的,并不是奶牛想住进来就住进来,超出棚 ...

  8. POJ 3617 Best Cow Line ||POJ 3069 Saruman's Army贪心

    带来两题贪心算法的题. 1.给定长度为N的字符串S,要构造一个长度为N的字符串T.起初,T是一个空串,随后反复进行下面两个操作:1.从S的头部删除一个字符,加到T的尾部.2.从S的尾部删除一个字符,加 ...

  9. POJ 3252:Round Numbers

    POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 36 ...

随机推荐

  1. 修改Git的name和email

    对于git的user.name 与user.email来说,有三个地方可以设置 etc/gitconfig (几乎不常用) git config --system ~/.gitconfig(对于单个用 ...

  2. Verilog有符号整型数(signed int)比大小

    本文参考了https://blog.csdn.net/wenxinwukui234/article/details/42119265/ 关于2进制补码的思考和讨论. ================= ...

  3. extract()和extact_first()的区别

    extract()和extact_first()都是提取Selector的data部分.但现在你要先知道什么是Selector. Selector是选择器的意思.具体定义我不知道,但通过下面的例子,你 ...

  4. python-模块加密hashlib

    import hashlib# md5ybm_pwd='yuanbapqingsdfs234FF234HF@F' #m = hashlib.md5() #bytes_ybq = ybm_pwd.enc ...

  5. 查看 Secret【转】

    可以通过 kubectl get secret 查看存在的 secret. 显示有两个数据条目,kubectl describe secret 查看条目的 Key: 如果还想查看 Value,可以用  ...

  6. Windows 10工程版本泄露全新设计的操作中心圆角样式

    早些时候微软错误地向Windows 10所有测试通道推送内部工程版本,该版本构建后尚未经过微软内部测试. 当然本身微软也没准备推送所以该版本里很多新功能未被关闭,而成功升级的用户则可以立即查看这些功能 ...

  7. 51nod 1163:最高的奖励 优先队列

    1163 最高的奖励 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题  收藏  关注 有N个任务,每个任务有一个最晚结束时间以及一个对应的奖励.在结束时间之前完成该 ...

  8. linux7下nenux3.14的maven私服搭建和配置使用

    为什么用私服,各种帖子很多,话不多说,直接奉上本博主的搭建过程. 一.环境准备:确保jdk和maven安装完成 二.下载nenux:地址:https://www.sonatype.com/downlo ...

  9. springmvc 后台实体类接受前端json字符串时,其中一个属性content 接受富文本内容时 标签<p>、<span> 这些标签丢失问题解决

    问题描述: 前端一个字段 <script id="editor" type="text/plain" name="content" s ...

  10. 【LeetCode】字符串中的第一个唯一字符

    [问题]给定一个字符串,找到它的第一个不重复的字符,并返回它的索引.如果不存在,则返回 -1. s = "leetcode" 返回 . s = "loveleetcode ...