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. BSGS 算法

    求解 A^x ≡ B mod C  C是质数 的最小非负整数解 证明:A^x ≡ A^(x%φ(C)) mod C A^(x%φ(C))  ≡ A^(x-k*φ(C)) ≡ (A^x)/ A^(k*φ ...

  2. Codeforces Round #477 (rated, Div. 2, based on VK Cup 2018 Round 3) F 构造

    http://codeforces.com/contest/967/problem/F 题目大意: 有n个点,n*(n-1)/2条边的无向图,其中有m条路目前开启(即能走),剩下的都是关闭状态 定义: ...

  3. [C]语法, 知识点总结(一. 进制, 格式化输入/出, 指针)

    进制 概念: n进制, 最大的数是n-1, 逢n进1位. 数据类型 概念: 其实就是占的位数不同, 转换到计算机当中都是0和1. 常用: 类型名 占字节数 描述 char 1字节=8个二进制位 字符类 ...

  4. html5 canvas贝塞尔曲线篇(上)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. 文件上传submit、ajax方式

    submit方式: <form id="postForm" name="postForm" action="${rc.contextPath}/ ...

  6. json 删除、添加对象

    1. 定义json对象    var entryJson = []; 2. 删除.添加对象 entryJson.pop();     //删除最后一个对象   entryJson.push({ //往 ...

  7. 【ARTS】01_02_左耳听风-20181119~1125

    Algorithm 做一个 leetcode 的算法题 Unique Email Addresses https://leetcode.com/problems/unique-email-addres ...

  8. Linux驱动中completion接口浅析(wait_for_complete例子,很好)

    completion是一种轻量级的机制,它允许一个线程告诉另一个线程工作已经完成.可以利用下面的宏静态创建completion:                          DECLARE_CO ...

  9. 使用pt-table-checksum校验MySQL主从复制【转】

    pt-table-checksum是一个基于MySQL数据库主从架构在线数据一致性校验工具.其工作原理在主库上运行, 通过对同步的表在主从段执行checksum, 从而判断数据是否一致.在校验完毕时, ...

  10. Bogus URL svn: is not properly URI-encoded

    问题描述: 从浏览器地址栏复制出来的url   放到eclipse 的svn插件里,新建资源库位置 总是报错 Bogus URL svn: **********************  is not ...