如果这次noip没考好,完全是因为从7月29日之后就没有再写过程序了。说起来,真是一个泪流满面的事实…

那这样一个弱智题练手恢复代码能力,竟然还花了我两个晚上(当然不是两整个晚上…)

第一天TLE了,好在我机智,一看到解题里说要压位就自动脑补出压位了。

代码风格非常诡异,弱智题竟然写到2KB我也是醉了。

program vijos_p1040;
const maxn=;
var a,b,aa,bb:array[..maxn] of integer;
c:array[..*maxn] of integer;
ma,mb,i,j,t,ca,cb:integer;
ch:char;
begin
//assign(input,'himul.in4');reset(input);
//assign(output,'himul.ou4');rewrite(output);
i:=;
//input num a
while not eoln do
begin
read(ch);
inc(i);
a[i]:=ord(ch)-ord('');
end;
ma:=i;
readln;
//reverse num a
for i:= to ma div do
begin
t:=a[i];a[i]:=a[ma-i+];a[ma-i+]:=t;
end;
//compress num a
for i:= to (ma div )+ do
aa[i]:=a[*i-]+a[*i]*;
//input num b
i:=;
while not eoln do
begin
read(ch);
inc(i);
b[i]:=ord(ch)-ord('');
end;
mb:=i;
//reverse num b
for i:= to mb div do
begin
t:=b[i];b[i]:=b[mb-i+];b[mb-i+]:=t;
end;
for i:= to (mb div )+ do
bb[i]:=b[*i-]+b[*i]*;
//multi
ca:=ma div +;
cb:=mb div +;
for i:= to cb do
begin
for j:= to ca do
begin
c[i+j-]:=c[i+j-]+aa[j]*bb[i];
if c[i+j-]>= then
begin
c[i+j]:=c[i+j]+c[i+j-] div ;
c[i+j-]:=c[i+j-] mod ;
end;
end;
end;
j:=ca+cb+;
while c[j]= do dec(j);
write(c[j]);
for i:=j- downto do
begin
if c[i]>= then write(c[i]) else write('',c[i]);
end;
writeln;
//close(input);close(output);
end.

高精度乘法

测试数据 #0: Accepted, time = 0 ms, mem = 732 KiB, score = 25

测试数据 #1: Accepted, time = 15 ms, mem = 732 KiB, score = 25

测试数据 #2: Accepted, time = 15 ms, mem = 736 KiB, score = 25

测试数据 #3: Accepted, time = 608 ms, mem = 732 KiB, score = 25

[vijos P1040] 高精度乘法的更多相关文章

  1. Vijos 1040 高精度乘法

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

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

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

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

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

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

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

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

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

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

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

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

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

  8. 高精度乘法--C++

    高精度乘法--C++ 模仿竖式乘法,在第一步计算的时候将进位保留,第一步计算完再处理进位.(见代码注释) 若要处理正负情况,可在数据输入后加以判断,处理比较简单. 小数计算也可参照该方法,不过对齐方式 ...

  9. C语言高精度乘法

    #include <stdio.h> void highPrecision (int N ); ] = {, }, length = ; //开辟一个大的数组,全局变量length记录长度 ...

随机推荐

  1. c++并发练习---生产者消费者模型

    问题:有一个生产者,多个消费者,生产者每生产一个,放入队列,多个消费者顺序从队列中取出数据,打印最终结果. 分析:首先这题,我本意应该设计成如下模型:生产者单开一个线程,向队列中放入数据,而消费者在锁 ...

  2. 去繁从简--简化Message和Signal设置

    以往的版本中如果添加了消息或者信号类型的事件需要先在流程属性(设置流程ID的界面)中添加Message和Signal,之后再选择对应的事件在属性中的下拉框中选择已经定义的Message或Signal. ...

  3. spice命令使用

    spicec.exe -h 192.168.1.1 -p 5912 -w 主机 物理机IP 端口号 主机

  4. js判断当前设备

    最近用bootstrap做自适应,发现仍然很难很好的兼容web端和PC端的现实. 仔细观察百度,淘宝,京东等大型网站,发现这些网站都有对应不同客户端的子站. 例如: 站点 PC端url web端url ...

  5. 转:OSGi 入门篇:生命周期层

    OSGi 入门篇:生命周期层 前言 生命周期层在OSGi框架中属于模块层上面的一层,它的运作是建立在模块层的功能之上的.生命周期层一个主要的功能就是让你能够从外部管理应用或者建立能够自我管理的应用(或 ...

  6. Hangfire项目使用

    基本介绍: hangfire 主要用于根据设置时间来执行任务,间隔几分钟执行一次,每天几点钟执行一次,如此执行任务. 方法: backgroundjob.enqueue(()=>"要执 ...

  7. MySQL DDL 整理

    DDL is Data Definition Language statements. Some examples:数据定义语言,用于定义和管理 SQL 数据库中的所有对象的语言 -- 清空表内容 T ...

  8. 更改make/bison的版本

    一.make版本 1.下载make的压缩包 ftp://ftp.gnu.org/gnu/make/ 2.解压,安装 cd make-x.x ./configuration sh build.sh su ...

  9. C++对于大型图片的加载缩放尝试

    Qt对于图片的操作主要集中在这几个类 QImage ,QImageReader ,QPixmap 其中QImage这个类对图片的缩放有几个很不错的技巧,不过对于大图片却并不好使,当我们去看QImage ...

  10. PE文件学习系列笔记四-C++实现PE文件的分析

    合肥程序员群:49313181.    合肥实名程序员群:128131462 (不愿透露姓名和信息者勿加入) Q  Q:408365330     E-Mail:egojit@qq.com 综述: 首 ...