C. Exponential notation

题目连接:

http://www.codeforces.com/contest/691/problem/C

Description

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 a and b.

English alphabet

You are given a string s. Check if the string is "s-palindrome".

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.

Sample Input

16

Sample Output

1.6E1

Hint

题意

给你一个数字,让你转化成科学计数法

题解:

记录第一个数字出现的位置,最后一个数字出线的位置,点出现的位置

然后瞎统计一下就好了

代码

#include<bits/stdc++.h>
using namespace std;
void p(int x){
if(x==0)return;
printf("E%d",x);
}
int main(){
string s;
cin>>s;
int a=-1,b=-1,c=s.size();
for(int i=0;i<s.size();i++){
if(s[i]=='.')c=i;
}
for(int i=0;i<s.size();i++){
if(s[i]=='0'||s[i]=='.')continue;
a=i;break;
}
for(int i=s.size()-1;i>=0;i--){
if(s[i]=='0'||s[i]=='.')continue;
b=i;break;
}
if(a==b){
printf("%c",s[a]);
if(c<a)p(c-a);//printf("E%d",c-a);
else p(c-a-1);//printf("E%d",c-a-1);
return 0;
}
cout<<s[a]<<".";
for(int i=a+1;i<=b;i++)
{
if(s[i]=='.')continue;
cout<<s[i];
}
if(c<a)p(c-a);//printf("E%d",c-a);
else p(c-a-1);//printf("E%d",c-a-1);
}

Educational Codeforces Round 14 C. Exponential notation 数字转科学计数法的更多相关文章

  1. 解决HTML导出Excel表数字变成科学计数法

    - js 中导出excel 较长数字串会变成科学计数法 在做项目中,碰到如题的问题.比如要将居民的信息导出到excel中,居民的身份证号码因为长度过长(大于10位),excel会自动的将过长的数字串转 ...

  2. java使用poi解析或处理excel的时候,如何防止数字变成科学计数法的形式和其他常见Excel中数据转换问题

    当使用POI处理excel的时候,遇到了比较长的数字,虽然excel里面设置该单元格是文本类型的,但是POI的cell的类型就会变成数字类型. 而且无论数字是否小数,使用cell.getNumberi ...

  3. mysql导出csv文件excel打开后数字用科学计数法显示且低位变0的解决方法

    Excel显示数字时,如果数字大于12位,它会自动转化为科学计数法:如果数字大于15位,它不仅用于科学技术费表示,还会只保留高15位,其他位都变0. Excel打开csv文件时,只要字段值都是数字,它 ...

  4. 导出csv用excel打开后数字不用科学计数法显示(0123456显示123456)

    从这儿抄过来的: http://zhejiangyinghui.iteye.com/blog/1149526 最近写了一个生成csv的程序,生成的csv其中有一列数字长度为13位,csv中查看没有问题 ...

  5. 解决navicat 导出excel数字为科学计数法问题

    1.原因分析      用程序导出的csv文件,当字段中有比较长的数字字段存在时,在用excel软件查看csv文件时就会变成科学技术法的表现形式.     其实这个问题跟用什么语言导出csv文件没有关 ...

  6. Laravel 使用 maatwebsite/excel 时长数字出现科学计数法的解决办法

    在使用 maatwebsite/excel 包导出Excel的时候,有的单元格里会存放手机号等一大串的数字,这一串数字会被Excel软件处理为科学计数法,在后续处理数据的时候会产生不小的麻烦,一个个去 ...

  7. Educational Codeforces Round 14

    A - Fashion in Berland 水 // #pragma comment(linker, "/STACK:102c000000,102c000000") #inclu ...

  8. php 解决返回数据 数字 变成科学计数法后转换问题

    链接 https://blog.csdn.net/liuxin_0725/article/details/81514961 问题 id int型 数字过长,json_decode的时候已经转成科学计数 ...

  9. Educational Codeforces Round 14 - F (codeforces 691F)

    题目链接:http://codeforces.com/problemset/problem/691/F 题目大意:给定n个数,再给m个询问,每个询问给一个p,求n个数中有多少对数的乘积≥p 数据范围: ...

随机推荐

  1. bzoj千题计划234:bzoj3802: Vocabulary

    http://www.lydsy.com/JudgeOnline/problem.php?id=3802 dp[i][0/1/2/3]  表示前i个字母,第1.2个字符串,第2.3个字符串的关系分别为 ...

  2. 原始套接字-TCP/IP下三层数据显示

    #include <stdio.h> #include <errno.h> #include <unistd.h> #include <sys/socket. ...

  3. Nginx 服务器性能Bug和性能优化方案(真实经历)

    一.遇到的问题 1.问题:本应该是3个ffmpeg ,但是怎么会有5个ffmpeg出现? 2.Lua脚本问题,一直写入日志,导致有大量的日志,这里的错误日志是直接写进nginx的error.log 日 ...

  4. 网络_OSI模型_数据包传输

    2017年1月12日, 星期四 网络_OSI模型_数据包传输 1.  网络_源主机_局域网_交换机_路由器_目标主机 2. OSI7七层_TCP/IP精简 OSI 7层:       应用层     ...

  5. springboot(五):springboot整合shiro-登录认证和权限管理

    http://z77z.oschina.io/ http://www.cnblogs.com/aqsunkai/category/982003.html https://www.cnblogs.com ...

  6. 20155338 2016-2017-2 《Java程序设计》第7周学习总结

    20155338 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 本周学习了第十二章和第十三章的内容,我重点学习了第十三章时间与日期的相关内容. 时间的度量: ...

  7. tf.Session()和tf.InteractiveSession()的区别

    官方tutorial是这么说的: The only difference with a regular Session is that an InteractiveSession installs i ...

  8. Jmeter如何保持cookie,让所有请求都能用同一个cookie,免去提取JSESSIONID

    近期有柠檬班的学生找到华华,问了一个问题,就是利用Jmeter做接口测试的时候,如何提取头部的JSESSIONID然后传递到下一个请求,继续完成当前用户的请求. 其实,关于这个问题有三种种解决方法: ...

  9. python的一个小原理

    在许多语言当中,类似于a.b()这样的调用方法是一个整体,但在Python中,它其实是两部分:获取属性a.b,调用().所以也可以写成: c = a.b c() 2.关于继承 class a: num ...

  10. 勒索软件Locky、Tesalcrypt等使用了新的工具躲避检测

    勒索软件Locky.Tesalcrypt等使用了新的工具躲避检测 今天我们发现Locky勒索软件家族使用一种新的工具来躲避检测,并且可能已经感染了很多节点. 自从我们通过AutoFocus智能威胁分析 ...