高精度乘法模板(luogu1303)
//luogu1303,不压位的高精度乘法
#include <cstdio>
#include <iostream> using namespace std; const int max_n=; int a[max_n],b[max_n],c[max_n];
string x,y; //字符串转数组(倒序)的函数
void swi(string s,int a[])
{
for (int i=;i<max_n;i++) a[i]=;
int n=s.size()-;
for (int i=n;i>=;i--)
{
a[]++;
a[a[]]=s[i]-'';
}
} //c=a*b
void multiply(int a[],int b[],int c[])
{
if (a[]== && a[]== || b[]== && b[]==)
{
c[]=;c[]=;return;
}
for (int i=;i<=a[]+b[];i++) c[i]=;
for (int i=;i<=a[];i++)
for (int j=;j<=b[];j++)
{
c[i+j-]+=a[i]*b[j];
c[i+j]+=c[i+j-]/;
c[i+j-]%=;
}
if (c[a[]+b[]]==) c[]=a[]+b[]-;
else c[]=a[]+b[];
} //输出c
void out(int a[])
{
for (int i=a[];i>;i--) printf("%d",a[i]);
}
int main()
{
cin>>x>>y;
swi(x,a);swi(y,b);
multiply(a,b,c);
out(c);
return ;
}
高精度乘法模板(luogu1303)的更多相关文章
- H. GSS and Simple Math Problem 高精度乘法模板
链接:https://www.nowcoder.com/acm/contest/104/G来源:牛客网 题目描述 Given n positive integers , your task is to ...
- [vijos P1040] 高精度乘法
如果这次noip没考好,完全是因为从7月29日之后就没有再写过程序了.说起来,真是一个泪流满面的事实… 那这样一个弱智题练手恢复代码能力,竟然还花了我两个晚上(当然不是两整个晚上…) 第一天TLE了, ...
- 【PKU1001】Exponentiation(高精度乘法)
Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 145642 Accepted: 35529 ...
- hdu 1042 N!(高精度乘法 + 缩进)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目大意:求n!, n 的上限是10000. 解题思路:高精度乘法 , 因为数据量比较大, 所以 ...
- hdu 1042 N!(高精度乘法)
Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in ...
- ACM高精度加减乘除模板
[转]#include <iostream> #include <string> using namespace std; inline int compare(string ...
- Vijos 1040 高精度乘法
描述 高精度乘法 输入:两行,每行表示一个非负整数(不超过10000位) 输出:两数的乘积. 样例1 样例输入1 99 101 样例输出1 9999 题解 这道题和之前的Vijos 1010 清帝之惑 ...
- 【POJ 1001】Exponentiation (高精度乘法+快速幂)
BUPT2017 wintertraining(15) #6A 题意 求\(R^n\) ( 0.0 < R < 99.999 )(0 < n <= 25) 题解 将R用字符串读 ...
- [leetcode]43. Multiply Strings高精度乘法
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and ...
随机推荐
- scrapy电影天堂实战(二)创建爬虫项目
公众号原文 创建数据库 我在上一篇笔记中已经创建了数据库,具体查看<scrapy电影天堂实战(一)创建数据库>,这篇笔记创建scrapy实例,先熟悉下要用到到xpath知识 用到的xpat ...
- DJango安装-windows
1.进入虚拟环境后启动 activate 2.查看当前虚拟环境是否存在Django环境 pip list 3.不存在则 安装Django环境 pip install django 4.查看Django ...
- 【FICO系列】SAP FICO模块-完工入库后的差异凭证处理
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[FICO系列]SAP FICO模块-完工入库后 ...
- MySQL 查询语句--------------进阶5:分组查询
#进阶5:分组查询 /* select 分组函数,列(要求出现在group by的后面) from 表 [where 筛选条件] group by 分组的列表 [order by 子句] 注意: 查询 ...
- 《JAVA设计模式》之桥接模式(Bridge)
在阎宏博士的<JAVA与模式>一书中开头是这样描述桥梁(Bridge)模式的: 桥梁模式是对象的结构模式.又称为柄体(Handle and Body)模式或接口(Interface)模式. ...
- Python 学习笔记17 文本 - 读写
在我们的编程过程中,我们经常需要对文件进行读写操作. 在Python中,对文本的读写非常的方便,只需要简单的几行代码就可以实现. 我们首先新建一个文本文件"Text.txt", 里 ...
- Java双链表
一.概述 二.英雄类 class HeroNode { //值域 public int id; public String name; public String nickName; //指针域 pu ...
- 深入理解DiscoveryClient
Spring Cloud Commons 提供的抽象 最早的时候服务发现注册都是通过DiscoveryClient来实现的,随着版本变迁把DiscoveryClient服务注册抽离出来变成了Servi ...
- Vue2.0源码阅读笔记(四):nextTick
在阅读 nextTick 的源码之前,要先弄明白 JS 执行环境运行机制,介绍 JS 执行环境的事件循环机制的文章很多,大部分都阐述的比较笼统,甚至有些文章说的是错误的,以下为个人理解,如有错误, ...
- 69.Daily Temperatures(日常气温)
Level: Medium 题目描述: Given a list of daily temperatures T, return a list such that, for each day in ...