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. 本地同时安装python2和python3时pip报错

    引言: 安装完成后,想测试一下两个版本的pip是否都可以正常工作,结果python3的能正常工作,但是pip2 --version就会报错,报错信息如下: Traceback (most recent ...

  2. C编程常错项

    linux系统下C编程一般报错;1,使用sqrt开平方函数未定义,是因为math.h[库,头文件未包含]2,隐式申明与内建函数"XXXX"不兼容;上述问题所在,一般是因为使用exi ...

  3. linux case ${variable} in

    脚本实现划分考试等级层次;

  4. 自动化运维工具 SaltStack 在云计算环境中的实践

    http://www.talkwithtrend.com/Article/218473

  5. HTML5 ES6 语法基础

    // 解构赋值 let [a, b, c, [s,e],d] = ["aa", "bb", "cc", [12, 23], "dd ...

  6. docker 简单入门(一)

    本篇目录 写在最前面的话 docker概念介绍 镜像的概念.容器的概念 docker的安装介绍 写在最前面的话 大家好,首先跟大家说声对不起,我班门弄斧了,我本身是做系统开发,使用的语言是C#和JAV ...

  7. 使用seaborn制图(柱状图)

    import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sns # 设置风格, ...

  8. J2SE 8的输入输出--序列化

    1. 普通序列化 implements Serializable 继承Serializable接口 class Employee implements Serializable { private S ...

  9. 14 ConfigParse模块

    1.ConfigParse模块的基本概念 此模块用于生成和修改常见配置文档. ConfigParser 是用来读取配置文件的包. 配置文件的格式如下:中括号“[ ]”内包含的为section.sect ...

  10. 数组去重的三种方法 es6

    [1,2,3,4,5,6,7,8,9,2,2,3,3,4,1].filter(function(el,index,arr){ return (index === arr.indexOf(el)); } ...