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. 通过开源项目免费申请 IntelliJ IDEA license(激活码)

    通过github开源项目免费申请 IntelliJ IDEA license(激活码) 我用来申请的github开源项目:https://github.com/Linliquan/springboot ...

  2. [CISCN2019 华北赛区 Day1 Web2]ikun

    知识点:逻辑漏洞.jwt密钥破解.python反序列化漏洞 进入靶机查看源码: 提示需要买到lv6,注册账号发现给了1000块钱,根据ctf套路应该是用很低的价格买很贵的lv6,首页翻了几页都没发现l ...

  3. 还是应该立个flag

    6月份 开通博客的想法很简单,就是决定要学习C++和算法,写博客作为督促自己的一个方式,因为还没有系统的学习,自认为写博客或见解有些力所不及,决定先从自己的一篇随笔开始,因为我知道自己一旦开始,就会坚 ...

  4. 「NOIP2011」观光公交

    传送门 Luogu 解题思路 有点麻烦,幸好 \(O(n^2)\) 能过... 贪心地想一想,我们如果要用加速器,肯定是要选择车上人数最多的时段加速. 但是我们就会面临这样的情况: 加速了,带来了增益 ...

  5. JAVA虚拟机:内存回收策略及算法

    java虚拟机中的程序计数器区.虚拟机栈区.本地方法栈区3个区域是随着线程的创建而创建,随着线程的结束而结束时,内存自然得到回收,所以这三个区域不需要过多考虑内存的回收问题. java虚拟机中的方法区 ...

  6. S3C2440内存控制器详解

    S3C2440A Memory Map after Reset S3C2440的内存空间划分为不同的块,当CPU向内存控制器发出地址,内存控制器根据地址范围,发出对应片选信号到片选引脚,实现对不同设备 ...

  7. linux systemctl命令

    转自systemctl详解 systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起. 任务 旧指令 新指令 使某服务自动启动 chkconf ...

  8. 论文阅读:Blink-Fast Connectivity Recovery Entirely in the Data Plane

    1.背景 在网络中,链路故障的发生在所难免,为了降低故障带来的影响,就需要重新路由,将数据传输到合适的链路上.当因为链路故障发生处的不同,也有不同的解决方法. AS(Autonomous System ...

  9. 谈谈HashSet的存储原理及为什么重写equals必须重写hashcode方法

    HashSet的存储原理: 1.将要传入的数据根据系统的hash算法得到一个hash值: 2.根据hash值可以得出该数据在hash表中的位置: 3.判断该位置上是否有值,没有值则把数据插入进来:如果 ...

  10. 014-查看PHP的环境变量

    <?php print("你正在用文件的名字为: "); print(__FILE__); print(" <BR>\n"); print(& ...