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. cecium 笔记

    1.Build文件夹 整个拷贝到public文件下,便可使用 2.BingMap(必应地图) Key申请之后,到Build/Cecium/Cecium.js更改默认Key, i.defaultKey ...

  2. selenium+python自动化90-unittest多线程执行用例

    前言 假设执行一条脚本(.py)用例一分钟,那么100个脚本需要100分钟,当你的用例达到一千条时需要1000分钟,也就是16个多小时... 那么如何并行运行多个.py的脚本,节省时间呢?这就用到多线 ...

  3. 20165233 2017-2018-2 《Java程序设计》课程总结

    20165233 2017-2018-2 课程总结 每周作业链接汇总 第0周 预备作业1 我期望的师生关系 预备作业2 学习基础和C语言基础调查 预备作业3 Linux安装及学习 第1周 第1周作业 ...

  4. 0_Simple__vectorAdd + 0_Simple__vectorAdd_nvrtc + 0_Simple__vectorAddDrv

    ▶ 使用 CUDA Runtime API,运行时编译,Driver API 三种接口计算向量加法 ▶ 源代码,CUDA Runtime API #include <stdio.h> #i ...

  5. 15.Result配置详解

    转自:https://wenku.baidu.com/view/84fa86ae360cba1aa911da02.html 说明:在前面的许多案例中我们所用到的Action基本都继承自ActionSu ...

  6. spring cloud 消费者

    本消费者  加了 Hystrix, 为了后续监控用. 1. 依赖: <parent> <groupId>org.springframework.boot</groupId ...

  7. LitJson JavaScriptSerializer

    using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...

  8. Beta分布(转)

    背景 在Machine Learning中,有一个很常见的概率分布叫做Beta Distribution: 同时,你可能也见过Dirichelet Distribution: 那么Beta Distr ...

  9. Cannot resolve class or package 'dbcp' Cannot resolve class 'BasicDataSource'

    在applicationContext.xml中配置数据源时,报错如下: Cannot resolve class or package 'dbcp' Cannot resolve class 'Ba ...

  10. phpStudy3——往数据库中添加数据

    前言: 前边介绍了查询数据库的方法,这里介绍下往数据库中添加数据的方法. 项目需求: 用户在前端页面输入的用户名和手机号码,点击提交后后端判断手机号码是否已经存在.如果不存在,那么插入数据库到数据库, ...