高精度乘法模板(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 ...
随机推荐
- jsc2019_qualD Classified
题目大意 给你一个有n个点的完全图 求一种方案是的给边染色后任何一点不能沿一种颜色的边走奇数条边回到这个点 要求颜色数最少 分析 考场上输出格式打错见祖宗... 我们每次找一个最大二分图将其染一个新颜 ...
- C#联接序列
1. Concat() – 串联序列(有重复项) var healthFoods = new List<string> { "fruits", "veget ...
- 同步GitHub上fork的项目
最近在做“Python练习册,每天一个小程序”,fork了项目并贡献自己写的代码,项目还有其他人在贡献代码,每天都会更新,这就涉及到了自己fork的项目与原项目的同步更新问题,下面就是我最常用的方法. ...
- RMQ(连续相同最大值)
http://poj.org/problem?id=3368 Frequent values Time Limit: 2000MS Memory Limit: 65536K Total Submi ...
- 洛谷 P1886 滑动窗口(单调队列)
题目链接 https://www.luogu.org/problemnew/show/P1886 题目描述 现在有一堆数字共N个数字(N<=10^6),以及一个大小为k的窗口.现在这个从左边开始 ...
- python——列表操作函数和方法
1.添加新元素 1.1 append()函数 描述:append() 方法用于在列表末尾添加新的对象. 语法:list.append(obj) 参数:obj -- 添加到列表末尾的对象. 返回值:该方 ...
- Task总结
1.Task的优势 ThreadPool相比Thread来说具备了很多优势,但是ThreadPool却又存在一些使用上的不方便.比如: ◆ ThreadPool不支持线程的取消.完成.失败通知等交互性 ...
- SR-IOV
SR-IOV 来源 http://blog.csdn.net/liushen0916/article/details/52423507 摘要: 介绍SR-IOV 的概念.使用场景.VMware 和 K ...
- differential evolution代码实例(DE算法)
DE算法是遗传算法中一种比较流行的算法,这种算法比较简单,速度也比较快,下面给出一份示例代码 clear all; close all; clc 2 %Function to be minimized ...
- XMPP即时通讯协议使用(七)——利用Strophe实现WebIM及strophe.plugins插件使用
Strophe简介与Openfire配置 Strophe.js是为XMPP写的一个js类库.因为http协议本身不能实现持久连接,所以strophe利用BOSH模拟实现持久连接. 官方文档: http ...