Educational Codeforces Round 14 C. Exponential notation 数字转科学计数法
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 数字转科学计数法的更多相关文章
- 解决HTML导出Excel表数字变成科学计数法
- js 中导出excel 较长数字串会变成科学计数法 在做项目中,碰到如题的问题.比如要将居民的信息导出到excel中,居民的身份证号码因为长度过长(大于10位),excel会自动的将过长的数字串转 ...
- java使用poi解析或处理excel的时候,如何防止数字变成科学计数法的形式和其他常见Excel中数据转换问题
当使用POI处理excel的时候,遇到了比较长的数字,虽然excel里面设置该单元格是文本类型的,但是POI的cell的类型就会变成数字类型. 而且无论数字是否小数,使用cell.getNumberi ...
- mysql导出csv文件excel打开后数字用科学计数法显示且低位变0的解决方法
Excel显示数字时,如果数字大于12位,它会自动转化为科学计数法:如果数字大于15位,它不仅用于科学技术费表示,还会只保留高15位,其他位都变0. Excel打开csv文件时,只要字段值都是数字,它 ...
- 导出csv用excel打开后数字不用科学计数法显示(0123456显示123456)
从这儿抄过来的: http://zhejiangyinghui.iteye.com/blog/1149526 最近写了一个生成csv的程序,生成的csv其中有一列数字长度为13位,csv中查看没有问题 ...
- 解决navicat 导出excel数字为科学计数法问题
1.原因分析 用程序导出的csv文件,当字段中有比较长的数字字段存在时,在用excel软件查看csv文件时就会变成科学技术法的表现形式. 其实这个问题跟用什么语言导出csv文件没有关 ...
- Laravel 使用 maatwebsite/excel 时长数字出现科学计数法的解决办法
在使用 maatwebsite/excel 包导出Excel的时候,有的单元格里会存放手机号等一大串的数字,这一串数字会被Excel软件处理为科学计数法,在后续处理数据的时候会产生不小的麻烦,一个个去 ...
- Educational Codeforces Round 14
A - Fashion in Berland 水 // #pragma comment(linker, "/STACK:102c000000,102c000000") #inclu ...
- php 解决返回数据 数字 变成科学计数法后转换问题
链接 https://blog.csdn.net/liuxin_0725/article/details/81514961 问题 id int型 数字过长,json_decode的时候已经转成科学计数 ...
- Educational Codeforces Round 14 - F (codeforces 691F)
题目链接:http://codeforces.com/problemset/problem/691/F 题目大意:给定n个数,再给m个询问,每个询问给一个p,求n个数中有多少对数的乘积≥p 数据范围: ...
随机推荐
- web html 基础2
1.表格<table> 行 tr,没有列的说法,只是单元格td table里面只能仿tr,tr里面只能放td,td可以嵌套任何标签 表格属性 border 边框, cellspacing ...
- css中实现ul两端的li对齐外面边缘
其实就是设置ul的宽度大一些就好
- 从数据库存储,文件结构谈到B树,散列
昨天俱乐部内部办了一个讲座,关于常规数据库系统实现,听了之后有点混乱,于是花了很多时间特地查了一些资料,基本上自己感觉自己是明白了.特地写下来. 文章开头说明三点, 第一点,本文针对常规数据库,是为了 ...
- [整理]JS中的状态机
/*StateMachine*/ var StateMachine = (function(){ function StateMachine(opts){ this.current = opts.in ...
- Sortable.js
拖拽的时候主要由这几个事件完成, ondragstart 事件:当拖拽元素开始被拖拽的时候触发的事件,此事件作用在被拖曳元素上 ondragenter 事件:当拖曳元素进入目标元素的时候触发的事件,此 ...
- HTML5 CSS Reset
最近在学习HTML和CSS,发现一个不错的模板,放于此处. /* html5doctor.com Reset Stylesheet v1.6.1 Last Updated: 2010-09-17 Au ...
- SVM Kernel Functions
==================================================================== This article came from here. Th ...
- lucene入门创建索引——(二)
1.程序宏观结构图
- Socket心跳包机制【转】
转自:https://blog.csdn.net/xuyuefei1988/article/details/8279812 心跳包的发送,通常有两种技术 方法1:应用层自己实现的心跳包 由应用程序自己 ...
- rtop:一个通过 SSH 监控远程主机的交互式工具【转】
编译自: http://www.tecmint.com/rtop-monitor-remote-linux-server-over-ssh/ rtop[1] 是一个基于 SSH 的直接的交互式远程系统 ...