A+B Problem(高精)
来源:互联网 发布:进销存软件行业 编辑:程序博客网 时间:2024/05/12 09:07
题目描述
高精度加法,x相当于a+b problem,[b][color=red]不用考虑负数[/color][/b]
输入输出格式
输入格式:分两行输入a,b<=10^500
输出格式:输出只有一行,代表A+B的值
输入输出样例
输入样例#1:
11
var x,y,ans:string; i,j,lena,lenb,lenc:longint; flag:boolean; a,b,c:array[0..10000]of longint; function calc(n:longint):longint; var i,j,k,l:longint; begin for i:=1 to n do begin c[i]:=c[i]+a[i]+b[i]; inc(c[i+1],c[i] div 10); c[i]:=c[i] mod 10; end; if c[n+1]<>0 then exit(n+1); exit(n); end;begin readln(x); readln(y); lena:=length(x); lenb:=length(y); for i:=1 to lena do a[lena-i+1]:=ord(x[i])-ord('0'); for i:=1 to lenb do b[lenb-i+1]:=ord(y[i])-ord('0'); lenc:=calc(max(lena,lenb)); for i:=lenc downto 1 do if (flag=false)and(c[i]=0) then continue else begin write(c[i]); flag:=true; end; if flag=false then writeln(0);end.
输出样例#1:
2
0 0
- P1601 A+B Problem(高精)
- A+B Problem(高精)
- A+B Problem(高精)
- P1601 A+B Problem(高精)
- 高精度加法 洛谷 P1601 A+B Problem(高精)
- 洛谷 P1601 A+B Problem(高精)
- 高精度——A+B Problem(高精)
- 【洛谷 1601】A+B Problem(高精)
- 【给将来学神的算法详解--高精】(3)A+B Problem
- 洛谷 1601 A+B Problem(高精)(The Last Problem In MY Winter Holiday,the Thirtieth)
- A+B Problem(V)
- A+B Problem(水)
- (1)A+B Problem
- A+B Problem(V)
- A+B Problem(V)
- A+B Problem(高精加)
- A+B Problem(V)
- A+B Problem(V)
- 蓝桥杯之全排列函数next_permutation()运用
- turn page for ngui
- 写博客的原因
- opencv:矩阵和图像操作
- 【每日记录】485集中器制作体会
- A+B Problem(高精)
- JavaScript跨域总结与解决办法
- java多线程(4)-- volatile原理与技巧
- Php学习之each() 函数详解
- 关于webview用法 以及全屏和隐藏标题栏
- git shell 命令大全
- 彻底删除kafka的topic方法
- opencv:绘图
- 二叉排序树