题目链接:51nod 1027大数乘法

直接模板了。

 #include<cstdio>
#include<cstring>
using namespace std;
const int N = ;
const int DLEN = ;
const int mod = ;
int alen, blen;
int ans_len;
char a1[N], b1[N];
int a[], b[];
int ans[]; void BigInt(const char s[], int (&c)[], int &len){
memset(c, , sizeof(c));
int L = strlen(s);
len = L / DLEN;
if(L%DLEN) len++;
int cnt = ;
for(int i = L-; i >= ; i -= DLEN){
int k = i - DLEN + ;
if(k < ) k = ;
int t = ;
for(int j = k; j <= i; ++j)
t = t * + s[j] - '';
c[cnt++] = t;
}
}
void multi(){
int i, j;
for(i = ; i < alen; ++i){
int up = ;
for(j = ; j < blen; ++j){
int t = a[i] * b[j] + ans[i+j] + up;
up = t / mod;
ans[i+j] = t % mod;
}
if(up != )
ans[i+j] = up;
}
ans_len = alen + blen;
while(ans[ans_len-] == && ans_len > )
ans_len--; printf("%d", ans[ans_len-]);
for(i = ans_len-; i >= ; i--)
printf("%04d", ans[i]);
puts("");
}
int main(){
scanf("%s%s", a1, b1);
BigInt(a1, a, alen);
BigInt(b1, b, blen);
multi();
return ;
}

51nod 1027大数乘法的更多相关文章

  1. 51NOD 1027 大数乘法

    1027 大数乘法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题   给出2个大整数A,B,计算A*B的结果.   Input 第1行:大数A 第2行:大数B (A,B ...

  2. 51 Nod 1027 大数乘法【Java大数乱搞】

    1027 大数乘法 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A,B的长度  ...

  3. 51Nod 1028 大数乘法 V2

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1028 分析: FFT/NTT板子题... 代码: NTT板子: #inc ...

  4. FFT/NTT [51Nod 1028] 大数乘法 V2

    题目链接:51Nod 传送门 没压位,效率会低一点 1.FFT #include <cstdio> #include <cstring> #include <algori ...

  5. 51nod 1028 大数乘法 V2 【FFT模板题】

    题目链接 模板题.. #include<bits/stdc++.h> using namespace std; typedef int LL; typedef double db; nam ...

  6. 51 Nod 1028 大数乘法 V2【Java大数乱搞】

    1028 大数乘法 V2 基准时间限制:2 秒 空间限制:131072 KB 分值: 80 难度:5级算法题 给出2个大整数A,B,计算A*B的结果. Input 第1行:大数A 第2行:大数B (A ...

  7. ACM学习历程—51NOD1028 大数乘法V2(FFT)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1028 题目大意就是求两个大数的乘法. 但是用普通的大数乘法,这 ...

  8. [POJ] #1001# Exponentiation : 大数乘法

    一. 题目 Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 156373   Accepted: ...

  9. 用分治法实现大数乘法,加法,减法(java实现)

    大数乘法即多项式乘法问题,求A(x)与B(x)的乘积C(x),朴素解法的复杂度O(n^2),基本思想是把多项式A(x)与B(x)写成 A(x)=a*x^m+b B(x)=c*x^m+d 其中a,b,c ...

随机推荐

  1. curl 查看一个web站点的响应时间(rt)

    1. curl 查看web站点rt curl -o /dev/null -s -w %{time_namelookup}::%{time_connect}::%{time_starttransfer} ...

  2. Java基础之在窗口中绘图——填充星型(StarApplet 2 filled stars)

    Applet程序. import javax.swing.*; import java.awt.*; import java.awt.geom.GeneralPath; @SuppressWarnin ...

  3. 微信端应用 ionic实现texarea 自适应高度

    最近公司项目,做微信端用到texarea 需要实现自适应高度的功能 当然自适应高度的方法很多网上找一大片,最直接的方式就是在使用到texarea的controller中添加js代码事件来实现,这中方式 ...

  4. startssl,免费的ssl证书申请及注意事项

    免费的ssl证书,https://www.startssl.com/ 安装到IIS和Nginx有所不同.原文 http://blog.newnaw.com/?p=1232 ------------转自 ...

  5. 移动端网站的内容触摸滑动-Swiper插件

    手机平板等大多移动端站点都会有触摸滑动内容的功能,公司移动端站点(m.muzhiwan.com)的标题广告滑动以及轮播效果就是用的Swiper插件. Swiper就是常用于移动端网站的内容触摸滑动的一 ...

  6. php curl的使用

    我们来采集一个页面,通常情况下,我们会使用file_get_contents()函数来获取: <?php $str = file_get_contents('http://www.baidu.c ...

  7. POJ 2876 Cantoring Along

    Description The Cantor set was discovered by Georg Cantor. It is one of the simpler fractals. It is ...

  8. ie11媒体查询以及其他hack

    <!doctype html> <html> <head> <title>IE10/11 Media Query Test</title> ...

  9. (4) 深入理解Java Class文件格式(三)

    转载:http://blog.csdn.net/zhangjg_blog/article/details/21557357 首先, 让我们回顾一下关于class文件格式的之前两篇博客的主要内容. 在  ...

  10. Visual Studio的Web Performance Test提取规则详解(3)

    总结 Visual Studio的Web Performance Test是基于HTTP协议层的,它不依赖于浏览器,通过直接接收,发送HTTP包来和Web服务器交互.Web Performance T ...