[vijos P1040] 高精度乘法
如果这次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] 高精度乘法的更多相关文章
- Vijos 1040 高精度乘法
描述 高精度乘法 输入:两行,每行表示一个非负整数(不超过10000位) 输出:两数的乘积. 样例1 样例输入1 99 101 样例输出1 9999 题解 这道题和之前的Vijos 1010 清帝之惑 ...
- 【PKU1001】Exponentiation(高精度乘法)
Exponentiation Time Limit: 500MS Memory Limit: 10000K Total Submissions: 145642 Accepted: 35529 ...
- hdu 1042 N!(高精度乘法 + 缩进)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1042 题目大意:求n!, n 的上限是10000. 解题思路:高精度乘法 , 因为数据量比较大, 所以 ...
- hdu 1042 N!(高精度乘法)
Problem Description Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in ...
- 【POJ 1001】Exponentiation (高精度乘法+快速幂)
BUPT2017 wintertraining(15) #6A 题意 求\(R^n\) ( 0.0 < R < 99.999 )(0 < n <= 25) 题解 将R用字符串读 ...
- [leetcode]43. Multiply Strings高精度乘法
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and ...
- H. GSS and Simple Math Problem 高精度乘法模板
链接:https://www.nowcoder.com/acm/contest/104/G来源:牛客网 题目描述 Given n positive integers , your task is to ...
- 高精度乘法--C++
高精度乘法--C++ 模仿竖式乘法,在第一步计算的时候将进位保留,第一步计算完再处理进位.(见代码注释) 若要处理正负情况,可在数据输入后加以判断,处理比较简单. 小数计算也可参照该方法,不过对齐方式 ...
- C语言高精度乘法
#include <stdio.h> void highPrecision (int N ); ] = {, }, length = ; //开辟一个大的数组,全局变量length记录长度 ...
随机推荐
- php : 基础(5)
函数 函数的定义: 形式: function 函数名 ( [$形参1] [,$形参2] [,.... ] ){ //函数体...... } 说明: 定义时使用的形参,其实就是一个变量--只能在该函数内 ...
- Java知识积累3-XML的DOM解析修改和删除方法
import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder;import jav ...
- (原创)QuartusII设置虚拟引脚(Virtual Pin)
方法一: 在Quartus II中Assignments->Assignment Editor, 在Category栏选择logic options, 到列表中To列下添加要设置的引脚接口,如果 ...
- 关于近期项目代码整理(iOS)
近期对项目中所经常使用到的封装代码进行整理,并将其上传至网络保存,本人会在后期不间断的更新其内容.具体链接地址为代码封装 关于代码 这些代码为从学习iOS来到现在实际项目开发中,精炼出来的封装代码,使 ...
- WPF感悟
WPF感悟 UI层与逻辑层要尽可能地剥离(解耦). Routed Event和Command比Event的耦合度要低. UI层与逻辑层的“血管”是数据关联(Data Binding). 尽量不要试图通 ...
- Android Fragment 深度解析
1.Fragment的产生与介绍 Android运行在各种各样的设备中,有小屏幕的手机,超大屏的平板甚至电视.针对屏幕尺寸的差距,很多情况下,都是先针对手机开发一套app,然后拷贝一份,修改布局以适应 ...
- VS后台程序无法调用App_Code里的公共类解决方案
在Web应用程序中不能通过右键项目-〉”添加“-〉”添加ASP.NET文件夹“方式添加 .因为Web应用程序中App_Code就不存在 .不过可以通过手动的方式创建,添加一个文件夹命名为App_Cod ...
- ireport5.6+jasperreport6.3开发(四)--以javabean为基准的报表开发(ireport)
javabean完成以后就是添加ireport的报表了 打开ireport的option然后在classpath中添加路径. 然后在ireport中追加数据源如图,点击图标后会出现数据源列表然后按ne ...
- web.xml中的contextConfigLocation在spring中的作用
在web.xml中通过contextConfigLocation配置spring, contextConfigLocation参数定义了要装入的 Spring 配置文件.默认会去/WEB-INF/下加 ...
- block,inline和inlinke-block细节对比
block,inline和inlinke-block细节对比 display:block block元素会独占一行,多个block元素会各自新起一行.默认情况下,block元素宽度自动填满其父元素宽度 ...