【模拟高精度+进制转换】数学序列

=============================

模拟高精加。

===================================

var
  d:array[char]of longint;
  dc:array[0..36]of char;
  a,b,c:array[1..201]of longint;
  a_l,b_l:longint;
  n:longint;
procedure init;
begin
  assign(input,'madition.in');
  assign(output,'madition.out');
  reset(input); rewrite(output);
end;

procedure terminate;
begin
  close(input); close(output);
  halt;
end;

procedure pre;
var
  ch:char;
  i:longint;
begin
  i:=10;
  for ch:='a' to 'z' do begin dc[i]:=ch; d[ch]:=i; inc(i); end;
  i:=0;
  for ch:='0' to '9' do begin dc[i]:=ch; d[ch]:=i; inc(i); end;
end;

procedure main;
var
  i:longint;
  st:string;
begin
  readln(n);
  fillchar(a,sizeof(a),0);
  fillchar(b,sizeof(b),0);
  fillchar(c,sizeof(c),0);
  
  readln(st);
  a_l:=length(st);
  for i:=1 to a_l do
    begin
      a[i]:=d[st[a_l+1-i]];
    end;
    
  readln(st);
  b_l:=length(st);
  for i:=1 to b_l do
    begin
      b[i]:=d[st[b_l+1-i]];
    end;
    
  if a_l<b_l then a_l:=b_l;
  for i:=1 to a_l do
    begin
      c[i]:=a[i]+b[i]+c[i];
      c[i+1]:=c[i] div n;
      c[i]:=c[i] mod n;
    end;
    
  if c[a_l]>n then
    begin
      c[a_l+1]:=c[a_l] div n;
      c[a_l]:=c[a_l] mod n;
      inc(a_l);
    end;
  if c[a_l+1]<>0 then inc(a_l);
  for i:=a_l downto 1 do
    write(dc[c[i]]);
end;

begin
  init;
  pre;
  main;
  terminate;
end.


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值