洛谷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. statistic_action

    方差variance 统计中的方差(样本方差)是每个样本值与全体样本值的平均数之差的平方值的平均数.V 离差平方和(Sum of Squares of Deviations)是各项与平均项之差的平方的 ...

  2. ruby的next if boolean

    next相当于continue

  3. JS-生成器函数(function 星号)的暂停和恢复(yield)

    https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/function* https://devel ...

  4. 124、TensorFlow替换函数

    # tf.device给你了很多可伸缩性在TensorFlow的计算图中选择放置你的单独的操作 # 在许多的情况下,有很多启发可以工作的很好 # 例如tf.train.replica_device_s ...

  5. python web自动化测试框架搭建(功能&接口)——接口公共方法

    接口公共方法有:数据引擎.http引擎.Excel引擎 1.数据引擎:获取用例.结果检查.结果统计 # -*- coding:utf-8 -*- from XlsEngine import XlsEn ...

  6. Fiddler抓包ios亲测

    1 打开Fiddler设置端口 2 设置可以抓取https选项 3 手机连接WIFI和电脑处于同一局域网并设置代理端口和fiddler中设置一致 4 证书安装手机浏览器输入代理电脑ip及端口如192. ...

  7. Unity3D架构之PureMVC

    之前了解过UI实现框架大多是用MVC架构的,才听说有这么一个基于MVC的跨平台开源框架叫PureMVC,前几天用到了做了一下,写一写分析总结官网位置:http://puremvc.org/ PureM ...

  8. 记一次 Json 对象转换为 Java 对象的问题

    1.描述 最近在使用 Jackson 将 Json 串转换回 Java 对象的时候遇到了 ClassCastException 错误,特此记述. 2.问题复现 问题出现的节点在于属性节点的 JavaT ...

  9. sqlalchemy的不区分大小写比较

    方法一:collation 参照:https://segmentfault.com/q/1010000010203547 方法是在 db.String 中添加 collation='NOCASE' 描 ...

  10. PHP学习:set_time_limit,max_execution_time,sleep

    set_time_limit 设置脚本最大允许执行时间,可以在php脚本中使用, 参数为秒,如果为0,表示无时间限制: set_time_limit(seconds); max_execution_t ...