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

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

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

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

  1. program vijos_p1040;
  2. const maxn=;
  3. var a,b,aa,bb:array[..maxn] of integer;
  4. c:array[..*maxn] of integer;
  5. ma,mb,i,j,t,ca,cb:integer;
  6. ch:char;
  7. begin
  8. //assign(input,'himul.in4');reset(input);
  9. //assign(output,'himul.ou4');rewrite(output);
  10. i:=;
  11. //input num a
  12. while not eoln do
  13. begin
  14. read(ch);
  15. inc(i);
  16. a[i]:=ord(ch)-ord('');
  17. end;
  18. ma:=i;
  19. readln;
  20. //reverse num a
  21. for i:= to ma div do
  22. begin
  23. t:=a[i];a[i]:=a[ma-i+];a[ma-i+]:=t;
  24. end;
  25. //compress num a
  26. for i:= to (ma div )+ do
  27. aa[i]:=a[*i-]+a[*i]*;
  28. //input num b
  29. i:=;
  30. while not eoln do
  31. begin
  32. read(ch);
  33. inc(i);
  34. b[i]:=ord(ch)-ord('');
  35. end;
  36. mb:=i;
  37. //reverse num b
  38. for i:= to mb div do
  39. begin
  40. t:=b[i];b[i]:=b[mb-i+];b[mb-i+]:=t;
  41. end;
  42. for i:= to (mb div )+ do
  43. bb[i]:=b[*i-]+b[*i]*;
  44. //multi
  45. ca:=ma div +;
  46. cb:=mb div +;
  47. for i:= to cb do
  48. begin
  49. for j:= to ca do
  50. begin
  51. c[i+j-]:=c[i+j-]+aa[j]*bb[i];
  52. if c[i+j-]>= then
  53. begin
  54. c[i+j]:=c[i+j]+c[i+j-] div ;
  55. c[i+j-]:=c[i+j-] mod ;
  56. end;
  57. end;
  58. end;
  59. j:=ca+cb+;
  60. while c[j]= do dec(j);
  61. write(c[j]);
  62. for i:=j- downto do
  63. begin
  64. if c[i]>= then write(c[i]) else write('',c[i]);
  65. end;
  66. writeln;
  67. //close(input);close(output);
  68. 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. JS中函数声明与函数表达式的不同

    Js中的函数声明是指下面的形式: function functionName(){   } 这样的方式来声明一个函数,而函数表达式则是类似表达式那样来声明一个函数,如 var functionName ...

  2. A little bit about Handlers in JAX-WS

    by Rama Pulavarthi Handlers are message interceptors that can be easily plugged in to the JAX-WS run ...

  3. CSRF token 无法被验证. ----Yii连接数据库后数据库错误日志报错

    CSRF token 无法被验证. 我使用的是mongodb+ yii1.1 What is CSRF, please see the details here.  http://en.wikiped ...

  4. Netscape HTTP Cooke File Parser In PHP

    http://www.hashbangcode.com/blog/netscape-http-cooke-file-parser-php I recently needed to create a f ...

  5. red hat安装mysql二进制包

    数据包命名格式解释 mysql-5.7.15-linux-glibc2.5-x86_64.tar.gz 黑色粗体表示为包名称 蓝色表示linux系统二进制包 红色表示构架     1.上传mysql- ...

  6. POI2005Bank notes银行货币

    Description Byteotian Bit Bank (BBB) 拥有一套先进的货币系统,这个系统一共有n种面值的硬币,面值分别为b1, b2,..., bn. 但是每种硬币有数量限制,现在我 ...

  7. 转!!MySQL中的存储引擎讲解(InnoDB,MyISAM,Memory等各存储引擎对比)

    MySQL中的存储引擎: 1.存储引擎的概念 2.查看MySQL所支持的存储引擎 3.MySQL中几种常用存储引擎的特点 4.存储引擎之间的相互转化 一.存储引擎: 1.存储引擎其实就是如何实现存储数 ...

  8. swagger for c# webapi

    最近迷上了前后端分离的开发架构,工作中的项目几乎都采取这种模式,自己主要担任服务端RestFul风格的Webapi开发.那么问题来了,当前端开发人员找我要api说明文档的时候,曾一度非常可耻的冒出过w ...

  9. 数据库查询优化-SQL优化

    1.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null可以在num上设置默 ...

  10. centos7

     1.启用Apache(httpd) Centos7默认已经安装httpd服务,只是没有启动.如果你需要全新安装,可以yum install -y httpd 启动服务:systemctl start ...