Barnicle(科学计数法转换)

                                         Barnicle

                                                                                  codeforce

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).

Examples

input

Copy

8.549e2

output

Copy

854.9

input

Copy

8.549e3

output

Copy

8549

input

Copy

0.33e0

output

Copy

0.33
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pii pair<ll,ll>
using namespace std;
int main()
{
    int a,b,len=0;
    char s[110],temp;
    scanf("%d",&a);
    scanf("%c",&temp);
    scanf("%c",&temp);
    while(temp!='e')
    {
        s[len++]=temp;
        scanf("%c",&temp);
    }
    scanf("%d",&b);

    if(a==0)
    {
        if(b==0&&len==1&&s[0]=='0')
        {
            printf("%d\n",a);
        }
        else
        {
            printf("0.");
            for(int i=0;i<len;i++)
                printf("%c",s[i]);
            puts("");
        }

    }
    else
    {
        if(b==0&&len==1&&s[0]=='0')
        {
            printf("%d\n",a);
        }
        else if(b>=len)
        {

            b-=len;
            printf("%d",a);
            for(int i=0;i<len;i++)
                printf("%c",s[i]);
            for(int i=0;i<b;i++)
                printf("0");
            puts("");
        }
        else
        {
            printf("%d",a);
            int i=0;
            for(i=0;i<b;i++)
                printf("%c",s[i]);
            printf(".");
            for(;i<len;i++)
                printf("%c",s[i]);
            puts("");
        }
    }

    return 0;
}

神一样的用法:

#include<stdio.h>
#include<cstring>
const int MYDD=1103;
 
int main() {
	int a,k,b;
	char d[MYDD];
	scanf("%d.",&a); //两个scanf不可合为一个
	scanf("%[^e]%ne%d",d,&k,&b);
	//note: "%[^e]" 读入任意多的字符,直到遇到 "=" 停止
	if(k==1&&d[0]==48&&!b) 	printf("%d\n",a);
	//note: 这里要是改为字符型判断d[0]=='0'时间复杂度增加一倍,可达到 30ms 
	else if(b>=k)				printf("%d%s%.*d\n",a,d,b-k,0);
	else 						printf("%d%.*s.%s\n",a,b,d,d+b);
						// 参数 b 输出字符串 d 的个数
	return 0;
}
 

猜你喜欢

转载自blog.csdn.net/sadsummerholiday/article/details/81393564