洛谷1303

 //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)的更多相关文章

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

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

  2. [vijos P1040] 高精度乘法

    如果这次noip没考好,完全是因为从7月29日之后就没有再写过程序了.说起来,真是一个泪流满面的事实… 那这样一个弱智题练手恢复代码能力,竟然还花了我两个晚上(当然不是两整个晚上…) 第一天TLE了, ...

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

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

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

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

  5. hdu 1042 N!(高精度乘法)

    Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!   Input One N in ...

  6. ACM高精度加减乘除模板

    [转]#include <iostream> #include <string> using namespace std; inline int compare(string ...

  7. Vijos 1040 高精度乘法

    描述 高精度乘法 输入:两行,每行表示一个非负整数(不超过10000位) 输出:两数的乘积. 样例1 样例输入1 99 101 样例输出1 9999 题解 这道题和之前的Vijos 1010 清帝之惑 ...

  8. 【POJ 1001】Exponentiation (高精度乘法+快速幂)

    BUPT2017 wintertraining(15) #6A 题意 求\(R^n\) ( 0.0 < R < 99.999 )(0 < n <= 25) 题解 将R用字符串读 ...

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

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

随机推荐

  1. P1022计算器の改良

    传送 这个题让你通过自己的努力,来写一个可以解一元一次方程的计算题(麻麻再也不用担心我计算错了qwq) 我们先学习一下一元一次方程的解法 step1:移项.把带有未知数的项移到方程的一边,把常数项移到 ...

  2. day35—JavaScript操作元素(创建、删除)

    转行学开发,代码100天——2018-04-20 JavaScript对DOM元素的创建.删除操作. 1.创建DOM元素 appendChild方法 createElement(ochild); op ...

  3. jmeter测试https请求

    测试https请求时,需要添加证书 目录 1.下载证书 2.导入 3.执行https请求 1.下载证书 在浏览器中打开要测试的https协议的网站,以谷歌为例打开,下载证书到桌面 4.一直点击下一步 ...

  4. 如何根据字典值的大小,对字典中的项排序---Python数据结构与算法相关问题与解决技巧

    实际案例: 某班英语成绩以字典形式存储为: { 'LiLei' : 90, 'Jim' : 88, 'Lucy': 92 } 如何根据成绩高低,计算学生排名 -- 根据分数,进行排名,并且把排名信息添 ...

  5. Comprehensive Guide to build a Recommendation Engine from scratch (in Python) / 从0开始搭建推荐系统

    https://www.analyticsvidhya.com/blog/2018/06/comprehensive-guide-recommendation-engine-python/, 一篇详细 ...

  6. JQ获取当前根目录

    function getRootPath_web() {            //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp  ...

  7. Django+python报错与解决方法

    编码信息导致修改django文件下的debug.py文件331行的编码格式 with Path(CURRENT_DIR, 'templates', 'technical_500.html').open ...

  8. vuejs基础-计算器案例

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  9. JedisPool使用注意事项

    转自:http://www.cnblogs.com/wangxin37/p/6397783.html JedisPool使用注意事项: 1.每次从pool获取资源后,一定要try-finally释放, ...

  10. [Linux] 005 Linux 常见目录的作用及一些注意事项

    1. Linux 常见目录及其作用 目录名 作用 /bin/ 存放系统命令的目录普通用户各超级用户都可以执行放在 /bin 下的命令在单用户模式下也可以执行 /sbin/ 保存和系统环境相关的命令只有 ...