POJ-3673 cow multiplition
来源:互联网 发布:淘宝怎么发布宝贝 编辑:程序博客网 时间:2024/06/05 23:58
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.
* Line 1: Two space-separated integers: A and B.
* Line 1: A single line that is the A*B in Bessie's style of multiplication.
123 45
54
这道题还是非常简单的,也就是用%和/来处理数据就好,但是在提交的时候出现了一个编译问题,也就是pow函数里面,要用10.0而不是10,是因为重载方面的问题,如果是10的话,那么就不知道该匹配哪个重载函数的参数,这个直接在编译器上没有问题,但是在oj上又出现了编译error,所以证明程序出错,都是程序员的错
#include<iostream>#include<math.h>using namespace std;#define N 15int main(){ long long a,b; while(cin>>a>>b) { int sum = 0; int i = 0; int value[N]; int valu2[N]; while(a>0) { int hee = i+1; long help = pow(10.0,hee); long he = pow(10.0,i); value[i] =(a%help)/he; a -= value[i]*pow(10.0,i); i++; //cout<<"a"<<" "<<a; } // cout<<endl; int j = 0; while(b>0) { int he = j+1; long help2 = pow(10.0,he); long hee = pow(10.0,j); valu2[j] = (b%help2)/hee; b-= valu2[j]*pow(10.0,j); j++; } /* for(int k = 0;k<i;k++) cout<<"value a "<<value[k]<<" "; cout<<endl; for(int t = 0;t<j;t++) cout<<"value b "<<valu2[t]<<" "; cout<<endl;*/ for(int k = 0;k<i;k++) for(int t = 0;t<j;t++) { sum += value[k] * valu2[t]; } cout<<sum<<endl; }}
0 0
- POJ-3673 cow multiplition
- 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 1946 Cow Cycling
- POJ 3176 COW BOWLING
- poj 1946 Cow Cycling
- POJ 3615 Cow Hurdles
- POJ 3176 Cow Bowling
- poj 3615 Cow Hurdles
- poj 3176 Cow Bowling
- POJ 3176 Cow Bowling
- 使用http client必须知道的参数设置及代码写法、存在的风险
- POJ 3995 Hop — Don’t Walk! 已被翻译
- JavaScript 设计模式入门和框架中的实践
- scala函数与方法
- 洛谷 1219——[USACO 1.5] 八皇后(深度优先搜索)
- POJ-3673 cow multiplition
- Android Studio与Unity的交互出现的错误
- 浅谈Django的Q查询以及AngularJS的Datatables分页插件
- 服务降级背后的技术架构设计
- 王垠:完全用Linux工作 (转载)
- 高性能高并发系统的稳定性保障
- 使用fetch post json数据的问题
- 分布式服务框架 Zookeeper -- 管理分布式环境中的数据
- java第十天