P1303 A*B Problem
题目描述
求两数的积。
输入输出格式
输入格式:
两个数
输出格式:
积
输入输出样例
1
2
2
说明
需用高精
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const int MAXN=;
char a1[MAXN],b1[MAXN];
int a[MAXN],b[MAXN];
int ans[MAXN];
int x;
int main()
{
scanf("%s%s",a1,b1);
int la=strlen(a1);
int lb=strlen(b1);
for(int i=;i<la;i++)
a[i]=a1[la-i-]-;
for(int i=;i<lb;i++)
b[i]=b1[lb-i-]-;
int lc=la*lb;
for(int i=;i<la;i++)
{
for(int j=;j<lb;j++)
{
ans[i+j]+=(a[i]*b[j]);
x=(ans[i+j])/;
ans[i+j]=ans[i+j]%;
ans[i+j+]+=x;
}
}
int flag=;
for(int i=lc;i>=;i--)
{
if(ans[i]==&&flag==&&i>)
continue;
else flag=;
printf("%d",ans[i]);
}
return ;
}
P1303 A*B Problem的更多相关文章
- 洛谷 P1303 A*B Problem
P1303 A*B Problem 题目描述 求两数的积. 输入输出格式 输入格式: 两行,两个数. 输出格式: 积 输入输出样例 输入样例#1: 复制 1 2 输出样例#1: 复制 2 说明 每个数 ...
- P1303 A*B Problem(高精度乘法)
P1303 A*B Problem 模拟就好了.\(c_ {i+j} +=a_i \times b_j\).时间复杂度 \(O(n*m)\) (FFT版可以做到 \(O((n+m)\log (n+m) ...
- 题解-洛谷P1303 A*B Problem(高精)
https://www.luogu.org/problemnew/show/P1303(题目传送门) 看到数据范围,显然要用高精度算法(乘法). 首先用字符串读下这最多达10^2000的数,并判断符号 ...
- 【洛谷P1303 A*B Problem】
题目描述 求两数的积. 输入输出格式 输入格式: 两行,两个数. 输出格式: 积 输入输出样例 输入样例#1: 1 2 输出样例#1: 2 说明 每个数字不超过10^2000,需用高精 emm,显然本 ...
- C++高精度模板
原文地址:http://blog.csdn.net/wall_f/article/details/8373395 原文只附代码,没有解析,本文增加了一些对代码的解释. 请注意:本模板不涉及实数运算与负 ...
- 洛谷【P1303】A*B Problem
题目传送门:https://www.luogu.org/problemnew/show/P1303 高精度乘法板子题,灵性地回忆一下小学时期列竖式的草稿纸即可. 时间复杂度:\(O(len^2)\) ...
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
随机推荐
- codeforces A. Kitahara Haruki's Gift 解题报告
题目链接:http://codeforces.com/problemset/problem/433/A 题目意思:给定 n 个只由100和200组成的数,问能不能分成均等的两份. 题目其实不难,要考虑 ...
- C语言变量声明问题——变量定义一定要放在所有执行语句/语句块的最前面吗?
报错信息:error C2065: 'salary' : undeclared identifier #include <stdio.h> void main(){ printf(&quo ...
- codeforces 690C2 C2. Brain Network (medium)(bfs+树的直径)
题目链接: C2. Brain Network (medium) time limit per test 2 seconds memory limit per test 256 megabytes i ...
- CF_576D_Flights for Regular Customers_矩阵乘法+倍增floyd+bitset+bfs
CF_576D_Flights for Regular Customers_矩阵乘法+倍增floyd+bitset https://www.luogu.org/problemnew/show/CF57 ...
- PostgreSQL 图形化客户端工具的使用技巧你都get了吗?
PostgreSQL 数据库作为目前功能较强大的开源数据库,得到了广泛应用.其中,TSA就用到了这款数据库来存储处理后的一些业务数据.虽然PostgreSQL自身提供了命令行交互式客户端工具psql, ...
- Code-NFine:jqgrid 数据绑定
ylbtech-Code-NFine:jqgrid 数据绑定 1. jqgrid 基本列展示返回顶部 1. 1.1..cshtml $(function () { gridList(); }) fun ...
- juju入门
https://jujucharms.com/docs/1.25/config-LXC Installation(Ubuntu) #sudo add-apt-repository ppa:juju/s ...
- Gym 100299C && UVaLive 6582 Magical GCD (暴力+数论)
题意:给出一个长度在 100 000 以内的正整数序列,大小不超过 10^ 12.求一个连续子序列,使得在所有的连续子序列中, 它们的GCD值乘以它们的长度最大. 析:暴力枚举右端点,然后在枚举左端点 ...
- P1229-神秘岛
神秘岛 描述 Description FireDancer来到一个神秘岛,他要从岛的西头到东头然后在东头的码头离开.可是当他走了一次后,发现这个岛的景色非常的美丽,于是他从东头的传送门传到了西头,换了 ...
- c 浮点科学计数法
浮点数 比喻1e1 e后面跟的是10的指数(也就是1的10次方,e表示10次方),f表示浮点数 1e1表示1×10¹,其实就是10 再例如5e2f,表示5×10²,也就是500 =========== ...