高精度乘法模板(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 ...
随机推荐
- p5414 [YNOI2019]排序
分析 这是真正的云南oi/px 我们需要考虑保留一段不降子序列 剩余的自由往前往后移动 所以dp一下即可 代码 #include<bits/stdc++.h> using namespac ...
- npm install 安装过程卡住不动
修改 npm 的安装目录下的 npmrc文件 增加一条 registry=http://registry.cnpmjs.org $ npm config set registry http://reg ...
- Vagrant 手册之 Vagrantfile - SSH 设置 config.ssh
原文地址 配置的命名空间:config.ssh config.ssh 中的设置与配置 Vagrant 如何通过 SSH 访问您的计算机相关. 大多数 Vagrant 设置一样,一般使用默认设置即可,但 ...
- hdu6333 Problem B. Harvest of Apples(组合数+莫队)
hdu6333 Problem B. Harvest of Apples 题目传送门 题意: 求(0,n)~(m,n)组合数之和 题解: C(n,m)=C(n-1,m-1)+C(n-1,m) 设 ...
- Quartz实现数据库动态配置定时任务
项目实战 或许实现的方式跟之前的代码有点不一样的 1.定时任务的配置信息 @Configuration public class ScheduleConfigration { @Autowired p ...
- java crm 系统 进销存 springmvc SSM项目项目源码
统介绍: 1.系统采用主流的 SSM 框架 jsp JSTL bootstrap html5 (PC浏览器使用) 2.springmvc +spring4.3.7+ mybaits3.3 SSM 普 ...
- JavaScript——正则匹配、正则提取、正则替换
正则匹配 // 匹配日期 var dateStr = '2015-10-10'; var reg = /^\d{4}-\d{1,2}-\d{1,2}$/ console.log(reg.test(da ...
- WEEX-EROS开发小笔记
本文是作者之前刚接触移动端跨平台开发,使用weex-eros开发项目平日里记下来的一些笔记,分享出来方便为新手解惑,weex-eros是weex的一套解决方法,使用vue语法糖,对于前端开发者来说可以 ...
- XMPP即时通讯协议使用(八)——基于订阅发布实现消息流转业务泳道图
- 理解Thread.sleep()函数
转载自:http://www.cnblogs.com/ILove/archive/2008/04/07/1140419.html 我们可能经常会用到 Thread.Sleep 函数来使线程挂起一段时间 ...