C. Exponential notation
time limit per test:

2 seconds

memory limit per test:256 megabytes
input:

standard input

output:

standard output

You are given a positive decimal number x.

Your task is to convert it to the "simple exponential notation".

Let x = a·10b, where 1 ≤ a < 10, then in general case the "simple exponential notation" looks like "aEb". If b equals to zero, the part "Eb" should be skipped. If a is an integer, it should be written without decimal point. Also there should not be extra zeroes in aand b.

Input

The only line contains the positive decimal number x. The length of the line will not exceed 106. Note that you are given too large number, so you can't use standard built-in data types "float", "double" and other.

Output

Print the only line — the "simple exponential notation" of the given number x.

Examples
input
16
output
1.6E1
input
01.23400
output
1.234
input
.100
output
1E-1
input
100.
output
1E2

题目链接:http://codeforces.com/problemset/problem/691/C

题意:就是把一个数转换成a*10^b(1≤a﹤10)形式,输出aEb。
思路:标记第一个不为零的数的位置作为起点s,标记最后一个不为零的数的位置作为终点e,标记小数点的位置sign,默认位置应该为len+1。根据三个位置进行输出。

代码:
#include<bits/stdc++.h>
using namespace std;
char x[];
int main()
{
int i;
scanf("%s",x);
int len=strlen(x);
int s=-,e=len-,sign=len;
for(i=; i<len; i++)
if(x[i]=='.')
{
sign=i;
break;
}
for(i=; i<len; i++)
if(x[i]>''&&x[i]<='')
{
s=i;
break;
}
for(i=len-; i>=; i--)
if(x[i]>''&&x[i]<='')
{
e=i;
break;
}
if(s>=)
{
cout<<x[s];
if(e>s) cout<<".";
for(i=s+; i<=e; i++)
if(x[i]!='.') cout<<x[i];
if((s+)!=sign)
{
cout<<"E";
if(s<sign) cout<<sign-s-<<endl;
else if(s>sign) cout<<sign-s<<endl;
}
}
else cout<<""<<endl;
return ;
}


 

Codeforces 691C. Exponential notation 模拟题的更多相关文章

  1. 【模拟】Codeforces 691C Exponential notation

    题目链接: http://codeforces.com/problemset/problem/691/C 题目大意: 输入一个数,把它表示成a·10b形式(aEb).输出aEb,1<=a< ...

  2. Codeforces 691C. Exponential notation

    题目链接:http://codeforces.com/problemset/problem/691/C 题意: 给你一个浮点数,让你把这个数转化为 aEb 的形式,含义为 a * 10b, 其中 a ...

  3. Codeforces 767B. The Queue 模拟题

    B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

  4. CF-697B Barnicle与691C Exponential notation

    无聊写两个题解吧,上午做比赛拉的,感触很多! B. Barnicle time limit per test 1 second memory limit per test 256 megabytes ...

  5. CodeForces - 344B Simple Molecules (模拟题)

    CodeForces - 344B id=46665" style="color:blue; text-decoration:none">Simple Molecu ...

  6. CodeForces - 344D Alternating Current (模拟题)

    id=46667" style="color:blue; text-decoration:none">CodeForces - 344D id=46667" ...

  7. CodeForces - 344E Read Time (模拟题 + 二分法)

    E. Read Time time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  8. CodeForces 681C Heap Operations (模拟题,优先队列)

    题意:给定 n 个按顺序的命令,但是可能有的命令不全,让你补全所有的命令,并且要求让总数最少. 析:没什么好说的,直接用优先队列模拟就行,insert,直接放入就行了,removeMin,就得判断一下 ...

  9. codeforces 691C C. Exponential notation(科学计数法)

    题目链接: C. Exponential notation time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

随机推荐

  1. springboot根据不同的条件创建bean,动态创建bean,@Conditional注解使用

    这个需求应该也比较常见,在不同的条件下创建不同的bean,具体场景很多,能看到这篇的肯定懂我的意思. 倘若不了解spring4.X新加入的@Conditional注解的话,要实现不同条件创建不同的be ...

  2. UVA540-队列

    题意: 每一个数字有自己所属的团队,如果所属的团队已经有人在队列里,放在团队的最后一个,要不然放队列里最后一个 注意:一个团队里的最多1000个元素,但是入队,出队的操作会达到200000次 解法:循 ...

  3. DDoS攻防战 (一) : 概述

    岁寒 然后知松柏之后凋也 ——论语·子罕 (此图摘自<Web脚本攻击与防御技术核心剖析>一书,作者:郝永清先生)    DDoS,即 Distributed Denial of Servi ...

  4. java 调用apache.commons.codec的包简单实现MD5加密

    转自:https://blog.csdn.net/mmd1234520/article/details/70210002/ import java.security.MessageDigest; im ...

  5. hashlib 加密模块使用说明

    import hashlib  #hashilib 模块 m = hashlib.md5() m.update('hello 天王盖地虎'.encode(encoding = 'utf-8)) m.h ...

  6. as3 有趣现象 关于声明与变量

    当使用了一个变量,并且前后期都没有在有效域内对此声明,不管有没有赋值,都会报错. 但先使用了一个变量,后期在有效域内对此声明,那么此变量不报错,但在声明之前没有赋值,那么赋值默认值:如果使用变量时,赋 ...

  7. python global nonlocal

    global: 方法之外在modual中的变量定义为全局变量.方法内的变量为局部变量. 一般情况下,全局变量可以被使用,但是不应该被修改,不然会报错. 不过一般不建议对全局变量做修改,如果有多个方法都 ...

  8. java常用的Utils写法

    Utils: 获取年龄 属性文件获取 BeanCopy    分页 MapUtils 获取年龄: /** * 根据传入的日期计算年龄,因时间戳是从1970年开始计算的 * @param date * ...

  9. python之建完model之后操作admin

    1)建完model 之后,运行./manage.py migrate 2)建立管理员:./manage.py createsuperuser 3)输入用户名和命令上提示的信息,在点击网址,输入admi ...

  10. 从底层谈WebGIS 原理设计与实现(六):WebGIS中地图瓦片在Canvas上的拼接显示原理

    从底层谈WebGIS 原理设计与实现(六):WebGIS中地图瓦片在Canvas上的拼接显示原理 作者:naaoveGI…    文章来源:naaoveGIS    点击数:1145    更新时间: ...