#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. JavaScript的 基本数据类型---对象

    第一:Javascript对象是 第二:Javascript中 第三:Javascript的对象是数据: 第四:JavaScript 中的对象可以简单理解成"名称:值"对(name ...

  2. 负载均衡之-LVS

    负载均衡用的很多,这里对负载均衡做一个总结吧,总共包含下面几片博文. LVS负载均衡 keepalived负载均衡+高可用 haproxy负载均衡 nginx负载均衡 LVS负载均衡 LVS是章文嵩博 ...

  3. NFS Iptables放行服务端口

    启动NFS会开启如下端口:1)portmapper 端口:111 udp/tcp:2)nfs/nfs_acl 端口:2049 udp/tcp:3)mountd 端口:"32768--6553 ...

  4. nginx location正则写法

    nginx location正则写法 一个示例: location = / { # 精确匹配 / ,主机名后面不能带任何字符串 [ configuration A ] } location / { # ...

  5. jsp拾遗

    JSP九大内置对象,七大动作,三大指令 https://blog.csdn.net/qq_34337272/article/details/64310849 JSP页面的静态包含和动态包含 https ...

  6. ubuntu12 root账户自动登录

    Ubuntu为了系统安全,root帐号的密码是随机的,如果临时需要提升至root权限以执行一些命令,需要使用sudo命令.产线上有几台使用Ubuntu的机器,因为使用者不固定,并且执行程序时需要使 用 ...

  7. Android程序示例

    目录 Android代码示例 OptionsMenu ImageButton CheckBox & RadioButton Context Menu快捷菜单 Key Event ListVie ...

  8. 【TCP/IP详解 卷一:协议】第四章 ARP:地址解析协议 以及其他部分的一些知识

    4.1 引言 数据链路 如以太网(Ethernet) 或者 令牌环网 都有自己的寻址机制(一般为 48 bit 的地址). 一个网络(数据链路层) 可以同时被多个不同的网络使用.比如,一组使用TCP/ ...

  9. go 并发

    package main import ( "fmt" "time" ) func say(s string) { ; i < ; i++ { time. ...

  10. nginx 跨域解决

    server { listen 8811 default_server; root /opt/bp; # Make site accessible from http://localhost/ ser ...