「NOIP2017模拟赛08.02」A**B
来源:互联网 发布:阿里云 discuz 编辑:程序博客网 时间:2024/05/22 17:26
题目链接:http://hhhoj.ngrok.cc/contest/3/problem/4
高精度乘法
小数点位数加一下就好了
注意前后的0以及输出规范
贴代码
type arr=array[0..300]of longint; var s:string; n,x,bo,i,j,t,len,bo1:longint; ans,a:arr; function mul(a,b:arr):arr; var i,j:longint; var c:arr; begin fillchar(c,sizeof(c),0); c[0]:=a[0]+b[0]-1; for i:=1 to a[0] do for j:=1 to b[0] do begin inc(c[i+j-1],a[i]*b[j]); inc(c[i+j],c[i+j-1]div 10); c[i+j-1]:=c[i+j-1]mod 10; end; if c[c[0]+1]>0 then inc(c[0]); exit(c); end;begin// assign(input,'1.in');reset(input);// assign(output,'1.out');rewrite(output); readln(s); if s[1]='.' then s:='0'+s; x:=pos(' ',s); bo:=0;val(copy(s,x+1,length(s)-x),n); for i:=1 to x-1 do if s[i]='.' then bo:=i; if bo<>0 then bo:=(x-1-bo)*n; while s[1]='0' do delete(s,1,1); len:=x-1; if s[1]='.' then delete(s,1,1); x:=pos(' ',s); len:=x-1;bo1:=0; for i:=1 to len do if s[i]='.' then bo1:=1; if bo1=1 then dec(len); i:=len;j:=1; a[0]:=len; while i>=1 do begin if s[j]='.' then inc(j); a[i]:=ord(s[j])-48; dec(i);inc(j); end; ans[0]:=1;ans[1]:=1; for t:=1 to n do ans:=mul(ans,a); if bo>=ans[0] then begin write('.'); for i:=1 to bo-ans[0] do write('0'); for i:=ans[0] downto 1 do write(ans[i]); end else begin for i:=1 to ans[0]-bo do write(ans[ans[0]-i+1]); if bo<>0 then write('.'); for i:=ans[0]-i downto 1 do write(ans[i]); end; // close(input);close(output); end.
【写的有漏洞的,欢迎路过大神吐槽】
2017/08/02 22:03:29
Ending.
阅读全文
0 0
- 「NOIP2017模拟赛08.02」A**B
- 【NOIP2017模拟赛】构造 A+B Problem(好题)
- 「NOIP2017模拟赛07.31」倒水
- 「NOIP2017模拟赛08.11」sequence
- 「NOIP2017模拟赛09.10」绝对值
- {小结}2017.04.15【NOIP2017提高组】模拟赛B组
- 2017.04.15【NOIP2017提高组】模拟赛B组总结
- 2017.04.15【NOIP2017提高组】模拟赛B组 总结
- 2017.04.15【NOIP2017提高组】模拟赛B组
- 2017.04.15【NOIP2017提高组】模拟赛B组
- 2017.04.15【NOIP2017提高组】模拟赛B组
- 2017.04.15【NOIP2017提高组】模拟赛B组题解
- 「NOIP2017模拟赛09.07」虐场
- 「NOIP2017模拟赛09.07」不解释连招
- 2017.08.18【NOIP2017提高组A组】模拟赛
- 2017.08.18【NOIP2017提高组A组】模拟赛
- 5379. 【NOIP2017提高A组模拟9.21】Victor爱数字 (2017.9B组)
- NOIP2017模拟赛1
- 正则表达式中各种字符的含义
- 开发微信小程序:创建小程序实例
- hdu1223(字母+字符动规)
- pyqt5 信号槽机制的官方文档笔记
- 课时15 Linux权限机制
- 「NOIP2017模拟赛08.02」A**B
- 有关input输入框内容改变后的触发事件
- Bootstrap中关于input里file的样式更改
- 二维码生成与解析代码实现
- 猴子也会懂的C语言五子棋的实现方法详解
- Spring-(4)Spring 注解
- P1226 取余运算||快速幂
- HDOJ 2120 Ice_cream's world I
- stm32的LCD屏幕显示+各个模块功能调试