Codeforces 691C. Exponential notation(模拟)

来源:互联网 发布:mac能pdf能转换成ppt吗 编辑:程序博客网 时间:2024/05/17 03:09

题目链接

简单题意

把给出的数转化成科学计数法,要求整数部分非零且只有一位

思路

按题意模拟就好,注意一下细节就行了。
Python大法好

代码

s = input()if not '.' in s: s += '.'a,b = s.strip('0').split('.')if len(a) > 0:  b = (a[1:] + b).rstrip('0')  le = len(a)-1  a = a[0]else:  le = len(b.strip('0')) - len(b) - 1  b = b.strip('0').rstrip('0')  a = b[0]  b = b[1:]print(a,end='')if len(b): print('.' + b,end='')if le : print('E'+str(le))
0 0
原创粉丝点击