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. git 查看一个分支是否被合并过

    1.查看该分支的提交历史 git log 分支名 2.git log master |grep comitid 如果包含,就证明已经合并过 3.git branch -d 分支名,如果报错,就是没合并 ...

  2. javascript 简单工厂模式

    var Bicycle = new Interface("Bicycle",["assemble","wash","ride&qu ...

  3. sql查询语句优化

    http://www.cnblogs.com/dubing/archive/2011/12/09/2278090.html 最近公司来一个非常虎的dba  10几年的经验 这里就称之为蔡老师吧 在征得 ...

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

    20155218 2016-2017-2 <Java程序设计>第7周学习总结 教材学习内容总结 就目前来说,即使标注为GMT(无论是文件说明,或者是API的日期时间字符串描述),实际上谈到 ...

  5. 线性筛的同时得到欧拉函数 (KuangBin板子)

    线性筛的思想:每个被筛的数是通过它最小的质因子所筛去的. 这种思想保证了每个数只会被筛一次,从而达到线性.并且,这个思想实现起来非常巧妙(见代码注释)! 因为线性筛的操作中用到了倍数的关系去实现,因此 ...

  6. 第9月第12天 lua_push lua_to luaL_check stack quick

    1. c代码中通过lua_push 把数据压入堆栈,lua调用c函数得到数据.luaL_check是对lua_to的封装,从堆栈中获取lua代码中函数调用的数据. static int lread(l ...

  7. 安装informatic过程中的错误

    1.Check if the DISPLAY variable is set export DISPLAY=192.168.3.201:0.0 在注销用户并切换到oracle或者infa 用户,就可以 ...

  8. 【ARTS】01_01_左耳听风-20181112~1116

    每周至少做一个 leetcode 的算法题.阅读并点评至少一篇英文技术文章.学习至少一个技术技巧.分享一篇有观点和思考的技术文章.(也就是 Algorithm.Review.Tip.Share 简称A ...

  9. python之celery使用详解(二)

    前言 前面我们了解了celery的基本使用后,现在对其常用的对象和方法进行分析. Celery对象 核心的对象就是Celery了,初始化方法: class Celery(object): def __ ...

  10. linux内存管理-内核用户空间 【转】

    转自:http://blog.chinaunix.net/uid-25909619-id-4491362.html 1,linux内存管理中几个重要的结构体和数组 page unsigned long ...