#include "bits/stdc++.h"
using namespace std;
char a[];
char b[]; int main()
{
while(cin >> a >> b)
{
int lena = strlen(a);
int lenb = strlen(b); for(int i=;i < ;i++)
a[i] = a[i] - '';
for(int i=;i < ;i++)
b[i] = b[i] - ''; int s[] = {};
int ans;
for(int i = lenb-;i>=;i--)
{
int k = lenb - - i;
for(int j = lena-;j >=;j--)
{
ans = s[k] + b[i] * a[j];
s[k] = ans < ? ans:ans%;
k++;
s[k] = s[k] + ans/;
}
}
// for(int i=0;i < 1000;i++)
// cout << s[i]; int m = ;
while(s[m] == )
m--;
while(m+)
{
cout << s[m];
m--;
} }
return ;
}

当我想用上次高精度减法的string模板的时候,发现了n多个bug,首先就是string之所以可以用于高精度的减法是因为字符和数组的差是一样的,而实际的数字是数字+48(或者其他什么东西),反正string的坑就是这个。还是用char进行初始化靠谱。

高精度乘法,string中的坑的更多相关文章

  1. Torch-RNN运行过程中的坑 [2](Lua的string sub函数,读取中文失败,乱码?)

    0.踩坑背景 仍然是torch-rnn/LanguageModel.lua文件中的一些问题,仍然是这个狗血的LM:encode_string函数: function LM:encode_string( ...

  2. 【手记】小心在where中使用NEWID()的大坑 【手记】解决启动SQL Server Management Studio 17时报Cannot find one of more components...的问题 【C#】组件分享:FormDragger窗体拖拽器 【手记】注意BinaryWriter写string的小坑——会在string前加上长度前缀length-prefixed

    [手记]小心在where中使用NEWID()的大坑 这个表达式: ABS(CHECKSUM(NEWID())) % 3 --把GUID弄成正整数,然后取模 是随机返回0.1.2这三个数,不可能返回其它 ...

  3. hdu 1042 N!(高精度乘法 + 缩进)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目大意:求n!, n 的上限是10000. 解题思路:高精度乘法 , 因为数据量比较大, 所以 ...

  4. H. GSS and Simple Math Problem 高精度乘法模板

    链接:https://www.nowcoder.com/acm/contest/104/G来源:牛客网 题目描述 Given n positive integers , your task is to ...

  5. 【PKU1001】Exponentiation(高精度乘法)

    Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 145642   Accepted: 35529 ...

  6. Golang中的坑二

    Golang中的坑二 for ...range 最近两周用Golang做项目,编写web服务,两周时间写了大概五千行代码(业务代码加单元测试用例代码).用Go的感觉很爽,编码效率高,运行效率也不错,用 ...

  7. Golang 中的坑 一

    Golang 中的坑 短变量声明  Short variable declarations 考虑如下代码: package main import ( "errors" " ...

  8. [leetcode]43. Multiply Strings高精度乘法

    Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and ...

  9. LightOJ 1024 Eid(高精度乘法+求n个数最小公约数)

    题目链接:https://vjudge.net/contest/28079#problem/T 题目大意:给你n个数求这些数的最小公倍数(约数). 解题思路:还太菜了,看了别人的题解才会写,转自这里, ...

随机推荐

  1. python之路----socketserver模块

    socketserver import socketserver class MyServer(socketserver.BaseRequestHandler): def handle(self): ...

  2. 文件和打印机共享 win7 and xp

    Win7 摘自:https://www.xp510.com/article/4249.html 首先开启服务 方法:开始---所有程序---附件---运行---输入services.msc----确定 ...

  3. js将时间戳转化为日期格式

    function getLocalTime(nS) {        var date = new Date(nS);        var Y = date.getFullYear() + '-'; ...

  4. JSP输出HTML时产生的大量空格和换行的去除方法

    在WEB应用中,如果使用jsp作为view层的显示模板,都会被空格/空换行问题所困扰.     这个问题当年也困扰了我比较长的时间.因为在jsp内使用的EL标签和其他标签时,会产生大量的空格和换行符. ...

  5. MySQL Crash Course #09# Chapter 17. Combining Queries: UNION

    INDEX UNION Rules WHERE VS. UNION UNION VS. UNION ALL Sorting Combined Query Results UNION Rules As ...

  6. bzoj1639 / P2884 [USACO07MAR]每月的费用Monthly Expense

    P2884 [USACO07MAR]每月的费用Monthly Expense 二分经典题 二分每个段的限制花费,顺便统计下最大段 注意可以分空段 #include<iostream> #i ...

  7. android CMakeLists

    https://developer.android.google.cn/studio/projects/configure-cmake https://blog.csdn.net/songmingzh ...

  8. 04:获取zabbix监控信息

    目录:Django其他篇 01: 安装zabbix server 02:zabbix-agent安装配置 及 web界面管理 03: zabbix API接口 对 主机.主机组.模板.应用集.监控项. ...

  9. 思考卷积神经网络(CNN)中各种意义

    原文:https://blog.csdn.net/aimreant/article/details/53145063 思考卷积神经网络(CNN)中各种意义 只是知道CNN是不够,我们需要对其进行解剖, ...

  10. Python3基础 函数 有参数有返回值 对传入的参数加1

             Python : 3.7.0          OS : Ubuntu 18.04.1 LTS         IDE : PyCharm 2018.2.4       Conda ...