Description

Bulls are so much better at math than the cows. They can multiply huge integers together and get perfectly precise answers … or so they say. Farmer John wonders if their answers are correct. Help him check the bulls’ answers. Read in two positive integers (no more than 40 digits each) and compute their product. Output it as a normal number (with no extra leading zeros).

FJ asks that you do this yourself; don’t use a special library function for the multiplication.
Input

  • Lines 1…2: Each line contains a single decimal number.
    Output

  • Line 1: The exact product of the two input lines

Sample Input

11111111111111
1111111111
Sample Output

12345679011110987654321
代码是模拟手算过程

#include<stdio.h>
#include<string.h>
int  read(int *am)
{int i=0;char st=getchar();while(st!='\n'){am[++i]=st-'0';st=getchar();}return i;
}
int main(void)
{int n1[50]={0};int n2[50]={0};int ans[100]={0};int carry=0;int size1=0,size2=0;size1=read(n1);size2=read(n2);int size=0;int k=0,tep;for(int j=size2;j>=1;j--,++k){size=k;//模拟加+for(int i=size1;i>=1;i--){tep=carry+ans[size]+n1[i]*n2[j];//顺便把上一次结果加进来,模拟运算ans[size++]=tep%10;carry=tep/10;}while(carry){ans[size++]=carry%10;carry/=10;}}for(int i=size-1;i>=0;i--){printf("%d",ans[i]);}
}

POJ 2389 Bull Math(大数乘大数)相关推荐

  1. POJ 2389 Bull Math(水~Java -大数相乘)

    题目链接:http://poj.org/problem?id=2389 题目大意: 大数相乘. 解题思路: java BigInteger类解决 o.0 AC Code: 1 import java. ...

  2. POJ 2389 Bull Math(FFT)

    Description 给出两个数A和B,求A*B Input 两个数字串,串长均不超过40 Output 输出两个串所表示数字的乘积 Sample Input 11111111111111 1111 ...

  3. 高精度乘法(正负数皆可(Bull Math)POJ)

    描述 高精度乘法 输入:两行,每行表示一个非负整数(不超过10000位) 输出:两数的乘积. 样例1 样例输入1 99 101 样例输出1 9999 #include<iostream> ...

  4. 【bzoj 1754】【POJ - 2389 】Bull Math (高精度运算)

    题干: Bulls are so much better at math than the cows. They can multiply huge integers together and get ...

  5. NUC1372 Bull Math【大数】

    Bull Math 时间限制: 1000ms 内存限制: 65535KB 通过次数: 1总提交次数: 1 问题描述 Bulls are so much better at math than the ...

  6. **【POJ - 2389】 Bull Math (高精度乘法)

    题干: Bulls are so much better at math than the cows. They can multiply huge integers together and get ...

  7. poj2389 Bull Math (高精度之A*B)

    题目来源:poj2389 Bull Math Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13350   Accepted ...

  8. 易语言 大数计算 大数支持库的使用实例

    部分数据过大需要使用到大数计算,网上暂时没看到简单的例子实例,所以记录下.希望能帮上需要的人. 以下代码直接复制到易语言即可使用.支持库里需要勾选上    数值计算支持库 EC模块下载地址:易语言大数 ...

  9. 【POJ - 1001 】Exponentiation (Java大数,高精度)

    题干: Problems involving the computation of exact values of very large magnitude and precision are com ...

最新文章

  1. 几道有意思的逻辑分析题
  2. 老男孩 - python基础day1
  3. Qt学习笔记之文件处理
  4. Windows SharePoint Services 3.0编码开发工具和技巧(Part 1 of 2)
  5. 3-18函数——作用域的查找空间
  6. python 类装饰器
  7. Directfb【01】 基础模块和基本运行机制介绍 -- 源码结构分析图
  8. 带着canvas去流浪系列之四 绘制散点图
  9. ~~高精度除以低精度
  10. python执行过程_Python threading模块condition原理及运行流程详解
  11. Discuz支持反对提示:抱歉您的请求来路不正确或表单无法提交的解决方法
  12. 自定义镜像迁移实例到新的区域(实例启动异常排解)
  13. Java算法面试题(009) 毒酒问题
  14. IOS平台车牌识别技术简介
  15. 基于vscode的vue开发环境搭建
  16. 应用加密大师计算机,Windows文件夹加密大师
  17. 高登复习笔记之Http网络协议和Servlet
  18. 亲自动手从源码 构建 Groovy 2.3.8 发布包
  19. linux运维 对比 网络_网络工程师和Linux运维工程师存在哪些差异
  20. 4G套餐用户挺住了,运营商比你们急,会给优惠的低价流量

热门文章

  1. 第24讲 | 比特币专题(一)历史与货币
  2. 如何实现最佳的跨平台游戏体验?Unity成亮解密实时渲染技术!
  3. Confluence5.1 最新版的安装破解汉化
  4. 在ActivMQ中添加jmx监控
  5. 模仿android谷歌地图功能开发记录
  6. IAR for msp430 MDK中 warning: #223-D: function xxx declared implicitly 解决方法
  7. 《Div+CSS 3.0网页布局案例精粹》扫描版[PDF]
  8. 设计模式----单件模式(c++)
  9. 编程小问题系列(6)——新年第一帖: 关于Silverlight在VS2010RC下无法正常运行的问题...
  10. ffmpeg播发器(H265)