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的更多相关文章
随机推荐
- JAVA包管理
package cn.java.mybole; class test6 { public static void main(String[] args) { System.out.println(&q ...
- Okam(奥卡姆):小程序开发框架
Okam(奥卡姆):小程序开发框架 Okam 是什么 `Okam` 一个面向小程序开发的开发框架,开发体验类 `Vue`.详情 Okam 对各小程序的支持情况 支持 百度小程序 支持 微信小程序 支持 ...
- What is the fastest way of (not) logging?
原文地址:http://www.slf4j.org/faq.html#logging_performance SLF4J supports an advanced feature called par ...
- 谈谈Copy-on-Write容器
1.简介 Copy-On-Write简称COW,是一种用于程序设计中的优化策略.其基本思路是,从一开始大家都在共享同一个内容,当某个人想要修改这个内容的时候,才会真正把内容Copy出去形成一个新的内容 ...
- ICLR 2013 International Conference on Learning Representations深度学习论文papers
ICLR 2013 International Conference on Learning Representations May 02 - 04, 2013, Scottsdale, Arizon ...
- 在Ubuntu 13.04下的安装eclipse
来源:http://www.cnblogs.com/lanxuezaipiao/p/3325628.html 一.eclipse安装过程 首先确保在安装eclipse之前已经安装好Java虚拟机 1. ...
- JDBC的批量插入操作
在今天之前,当我遇到需要使用JDBC对数据库进行批量插入操作的时候,我使用的方法如下: ①使用Connection建立数据库连接: ②使用PreparedStatement提交SQL语句,将数据插入: ...
- 设计模式实例(Lua)笔记之四(Builder 模式)
1.描写叙述: 又是一个周三,快要下班了,老大突然又拉住我,喜滋滋的告诉我"牛叉公司非常惬意我们做的模型,又签订了一个合同,把奔驰.宝马的车辆模型都交给我我们公司制作了,只是这次又 ...
- Android -- Broadcast接收
Broadcast是Android四大组件之一,是一种广泛运用的在应用程序之间传输信息的机制.最经典的举例是: “我们拿广播电台来做个比方.我们平常使用收音机收音是这样的:许许多多不同的广播电台通过特 ...
- iScroll示例,下拉刷新,上拉刷新
iScroll示例,下拉刷新,上拉刷新 <!DOCTYPE html> <html> <head> <meta http-equiv="Conten ...