POJ 3673 Cow Multiplication
来源:互联网 发布:卡五星房卡麻将源码 编辑:程序博客网 时间:2024/05/18 00:39
一、题目信息
Cow Multiplication
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 10216 Accepted: 6993
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
二、参考代码
为了避免使用%,/这些运算符,这里我采用字符串。
#include <stdio.h>int main(int argc,char * argv[]){ int i,j,tmp_a,result=0; char a[11],b[11]; scanf("%ld%ld",a,b); for(i = 0;i < strlen(a);i++){ tmp_a = a[i] - '0'; for(j = 0;j < strlen(b);j++) result += (a[i] - '0')*(b[j] - '0'); } printf("%ld\n",result); return 0;}
- poj 3673 Cow Multiplication
- POJ 3673 Cow Multiplication
- POJ 3673 Cow Multiplication
- POJ - 3673 Cow Multiplication
- POJ 3673:Cow Multiplication
- POJ 3673 Cow Multiplication
- POJ 3673 Cow Multiplication G++
- poj 3673 Cow Multiplication(水题)
- POJ 3673 Cow Multiplication(水~)
- 文章标题 POJ 3673 : Cow Multiplication (水)
- Cow Multiplication
- POJ3673----Cow Multiplication
- poj3673 Cow Multiplication
- POJ-3673 cow multiplition
- POJ 3318 Matrix Multiplication
- poj Multiplication Puzzle
- POJ 1651 Multiplication Puzzle
- Poj 1489 Egyptian Multiplication
- 怎么把ARGB1555 转化为 ARGB4444
- js 图片滚动的实现(整理别人的代码而得)
- eclipse/myeclipse的快捷键,开发技巧
- Ubuntu 10.10下Nginx-0.8.54安装
- 解决cp: omitting directory 提示信息
- POJ 3673 Cow Multiplication
- c语言结构体后定义*Ruler_ptr 含义
- 排序工作量
- xcode升级到4.4.1后 Suppress warning “Category is implementing a method which will also be implemented by
- 清理svn的垃圾文件.svn文件夹
- 1978到2008年间的12次暴富机遇,你抓住了几次?
- linux下U盘的挂载与退出
- 理解TCP为什么需要进行三次握手(白话)
- 伪代码