zoukankan      html  css  js  c++  java
  • Codeforces Round #362 (Div. 2)->B. Barnicle

    B. Barnicle
    time limit per test
    1 second
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    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 andx = 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 qis an integer that have no trailing zeroes (and may not be equal to zero).

    Examples
    input
    8.549e2
    output
    854.9
    input
    8.549e3
    output
    8549
    input
    0.33e0
    output
    0.33
    提醒:试试1.038e0,0.0e0,7.0e100,0.0e2这几个样例可以改好多次代码。。(我就是wa在这些)
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 char a[1000000]= {0};
     4 int main(void)
     5 {
     6     int ex=0;
     7     scanf("%c.%[0-9]e%d",&a[0],a+1,&ex);
     8     int len=strlen(a);
     9     int flag=0;
    10     for(int i=1; i<len; i++)
    11     {
    12         if(a[i]!='0')
    13         {
    14             flag=1;
    15         }
    16     }
    17     if(flag==0&&ex==0)
    18         printf("%c",a[0]);
    19     else
    20     {
    21         for(int i=0; i<ex+1||a[i]!=0; i++)
    22         {
    23             if(i==ex+1) printf(".");
    24             printf("%c",a[i]==0?'0':a[i]);
    25         }
    26     }
    27     printf("
    ");
    28     return 0;
    29 }
     
  • 相关阅读:
    死锁分析-(DML+DDL触发Server层死锁)
    archery 1.80推送工单到飞书webhook失败解决方案
    mysql执行计划 Select tables optimized away
    apparmor mysql_Ubuntu 上更改 MySQL 数据库数据存储目录
    查看docker容器的tcp连接(转)
    Mongo副本集搭建方式
    数据库字段命名方法
    C# DataGridview控件自动下拉到最后一行
    C# datagridview绑定List<string>显示的是数据长度
    DataGridView 清空数据
  • 原文地址:https://www.cnblogs.com/zhien-aa/p/5673592.html
Copyright © 2011-2022 走看看