cf 697b 科学记数法逆推

CodeForces - 697B
Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

 Status

Description

Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.

Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A × 10B is true. In our case A is between 0 and 9 and B is non-negative.

Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.

Input

The first and only line of input contains a single string of form a.deb where ad and b are integers and e is usual character 'e' (0 ≤ a ≤ 9, 0 ≤ d < 10100, 0 ≤ b ≤ 100) — the scientific notation of the desired distance value.

a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.

Output

Print the only real number x (the desired distance value) in the only line in its decimal notation.

Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.

Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).

Sample Input

Input
8.549e2
Output
854.9
Input
8.549e3
Output
8549
Input
0.33e0
Output
0.33
<span style="font-size:18px;">#include<cstdio>  
#include<cstring>  
#include<cmath>  
#include<iostream>  
#include<algorithm>  
using namespace std;  
int main()  
{  
    int a,d,i,j,k,s1,s2,k1,c[3];  
    char b[101],s[110];  
    while(~scanf("%s",&s))  
    {  
        k1=strlen(s);  
        a=(int)(s[0]);  
        k=0;  
        for(i=2; s[i]!='e'; i++)  
            b[k++]=s[i];  
        d=0,s2=0;  
        for(i=k1-1; s[i]!='e'; i--)  
        {  
            c[s2++]=s[i]-48;  
            for(j=0; j<s2-1; j++)  
                c[s2-1]*=10;  
            d+=c[s2-1];  
        }  
        if(a==0)  
            printf("0");  
        else printf("%c",a);  
        if(b[0]=='0'&&k==1&&d==0)  
        {  
            printf("\n");  
            continue;  
        }  
        if(k>=d)  
        {  
            for(i=0; i<d; i++)  
                printf("%c",b[i]);  
  
            if(k!=d)  
            {  
                printf(".");  
                for(i=d; i<k; i++)  
                    printf("%c",b[i]);  
            }  
        }  
        else  
        {  
            for(i=0; i<k; i++)  
                printf("%c",b[i]);  
            for(j=0; j<d-k; j++)  
                printf("0");  
        }  
        printf("\n");  
    }  
    return 0;  
}  </span>

全部评论

相关推荐

复制粘贴骂ai!
聪明的加菲猫又在摸鱼:我写论文也是这样,不断教育ai
点赞 评论 收藏
分享
05-01 22:41
中南大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务