Untitled

mail@pastecode.io avatar
unknown
python
2 months ago
492 B
8
Indexable
Never
n = int(input())
p = int(input())
val = n**p
length = len(str(val))

if length < 6:
    print(f'{n}^{p} = {val}')
else:
    new_val = (val/(10**(length-1)))
    be = str(new_val)[:6]
    
    ae = str(new_val)[6:].replace('0','')
    ae_length = len(ae)
    precision_bit = int(str(new_val)[6])+1 if (10**(ae_length)-int(ae) <= int(ae)) else str(new_val)[6]
    be += str(precision_bit)
    
    pow_bit = length-1 if length>10 else f'0{length-1}'
    
    print(f'{n}^{p} = {be}+e{pow_bit}')
Leave a Comment