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的更多相关文章
随机推荐
- Two-transistor circuit replaces IC
Linear Technology's recently introduced LTC4300 chip buffers I2C clock and data lines to and from a ...
- Circuit translates I2C voltages
This Design Idea explores level-shifting an I2C bus from 5V/ground (positive domain) to ground/–5V ( ...
- 微信公众平台—— 获取微信服务器IP地址
微信公众平台—— 获取微信服务器IP地址 const ServerIpUrl = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?&acces ...
- 《Linux兵书》
<Linux兵书> 基本信息 作者: 刘丽霞 杨宇 丛书名: 程序员藏经阁 出版社:电子工业出版社 ISBN:9787121219924 上架时间:2014-1-13 出版日期:20 ...
- Python学习(二)Python 简介
Python 简介 官方指南及文档 Python2.7官方指南(中文版):http://pan.baidu.com/s/1dDm18xr Python3.4官方指南(中文版):http://pan.b ...
- JavaScript hash
location.hash -- 返回URL#后面的内容,如果没有#,返回空 hash,中文"哈希" 引用网址:http://www.dreamdu.com/javascript/ ...
- spring+mybatis 多数据源切换
摘自: http://www.oschina.net/code/snippet_347813_12525 1. 代码: DbContextHolder public class DbContextHo ...
- php 上传视频的代码,
<html> <head> <meta http-equiv="Content-Type" content="text/html; char ...
- WeifenLuo.WinFormsUI.Docking添加关闭功能
/****************************************************************** * 创建人:HTL * 创建时间:2014-7-8 15:37: ...
- DotNetBar12.1新控件——TokenEditor
第一次接触第三方控件就是DotNetBar,现在官网已发布到12.2版本了,这里只能使用12.1破解版本,下载地址:http://www.t00y.com/file/92543094 在这个版本中出现 ...