Pku3673
<span style="color:#6600cc;">/*
B - Cow Multiplication
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Submit Status Practice POJ 3673
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
By Grant Yuan
2014.7.11
*/
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;
int main()
{
int sum=0;
char a[13],b[13];
memset(a,0,12);
memset(b,0,12); cin>>a>>b;
int i,j;
int o,q;
o=strlen(a);
q=strlen(b); int n1,n2;
for(i=0;i<o;i++)
for(j=0;j<q;j++)
{
n1=a[i]-48;
n2=b[j]-48;
sum+=n1*n2;
}
cout<<sum<<endl;
return 0; } </span>
Pku3673的更多相关文章
随机推荐
- Configuring spartan 6 using mcu and spi flash
http://forums.xilinx.com/t5/General-Technical-Discussion/Configuring-spartan-6-using-mcu-and-spi-fla ...
- PHP str_pad() 函数
str_pad() 函数把字符串填充为指定的长度. 进入 详细介绍页面
- CSS基础知识解析
一.基础知识 1.1 CSS组成 css 样式由选择符和声明组成,而声明又由属性和值组成,如下图所示: 选择符:又称选择器,指明网页中要应用样式规则的元素,如本例中是网页中所有的段(p)的文字将变成蓝 ...
- 如何编译Linux内核
内核,是一个操作系统的核心.它负责管理系统的进程.内存.设备驱动程序.文件和网络系统,决定着系统的性能和稳定性.Linux作为一个自由软件,在广 大爱好者的支持下,内核版本不断更新.新的内核修订了旧内 ...
- Android开发project师,前行路上的14项技能
导读: 你是否曾渴望回到宋朝? 或者什么朝,反正就是男耕女织的古代. 哦,那时的首都在汴梁(开封),房价想必没有如今这么高,工作?无非就是给你把锄头,去,种地去.夕阳西下了,麦子垛后,你和翠姑搂抱在一 ...
- poj3126--Prime Path(广搜)
Prime Path Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11751 Accepted: 6673 Descr ...
- maven编译错误,警告: BASE64Decoder是内部专用 API, 可能会在未来发行版中删除
修改红色部分版本号为2.3.2 <plugin> <groupId>org.apache.maven.plugins& ...
- [Android Studio] Android Studio如何提示函数用法
Eclipse有一个很好的功能,就是当你代码调用某个android API时,鼠标移到对应的函数或者方法上,就会自动有一个悬 浮窗提示该函数的说明(所包含的参数含义,该方法功能).迁移到Android ...
- 世界围棋人机大战、顶峰对决第一盘:围棋世界冠军Lee Sedol(李世石,围棋职业九段)对战Google DeepMind AlphaGo围棋程序
Match 1 - Google DeepMind Challenge Match: Lee Sedol vs AlphaGo 很多网站对世界围棋大战进行了现场直播,比如YouTube.新浪.乐视.腾 ...
- ASP.NET 5 的Roadmap(转)
这次随 Visual Studio 2015 发布的 ASP.NET 版本是 ASP.NET 4.6 与 ASP.NET 5 beta5.在 VS2015 发布的同时,微软也发布了 ASP.NET 5 ...