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. BenevolentAI | 基于知识图谱发现的COVID-19潜在治疗药物进入临床试验
  2. JavaScript学习笔记——对象知识点
  3. 正数数组的最小不可组成和
  4. 【bzoj 3173】[Tjoi2013]最长上升子序列
  5. pythonzip是迭代器_Python迭代器和zip
  6. Java 8的方法参考进一步限制了重载
  7. java删_JAVA删除文件夹
  8. python flask快速入门与进阶-Flask基础进阶与python flask实战bbs教程
  9. python_day9 回调函数
  10. java的finalize方法使用
  11. 安装debian 9.1后,中文环境下将home目录下文件夹改为对应的英文
  12. Golang GC算法解读
  13. Ubuntu20.04 conda安出错,成功解决:solving environment:failed with initial frozen solve.Retrying with flexibl
  14. electron解决下载慢(亲测有效)
  15. E+H 超声波液位计FMU40-ARD2A2 应用优势及应用领域
  16. java分布式实现图片上传到图片服务器
  17. 代码覆盖率工具BullseyeCoverage研究
  18. Unity 报错TLS Allocator ALLOC_TEMP_THREAD, underlying allocator ALLOC_TEMP_THREAD
  19. 快速记忆数学知识的六个方法
  20. TFTP 简单文件传输协议

热门文章

  1. 2020薪资排名第一的专业公布,除了计算机还有这些!
  2. 在html中引入css、js和jQuery的方法
  3. MySQL进阶SQL优化
  4. python scrapy 入门,10分钟完成一个爬虫
  5. sqlmap 常用操作
  6. PHP如何进阶,提升自己
  7. linux驱动开发要知道的那些知识(三)------container_of,定时器 及系统调用
  8. ConcurrentDictionary线程不安全么,你难道没疑惑,你难道弄懂了么?
  9. ArrayList, LinkedList , Vector
  10. zookeeper集群启动报错:Cannot open channel to * at election address /ip:3888