题目链接:

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

题意:

把给出的这个数用科学计数法法表示;

思路:

注意前导0,末尾的0,还有就是小数点的位置等;

AC代码:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath> using namespace std; #define For(i,j,n) for(int i=j;i<=n;i++)
#define mst(ss,b) memset(ss,b,sizeof(ss)); typedef long long LL; template<class T> void read(T&num) {
char CH; bool F=false;
for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
F && (num=-num);
}
int stk[70], tp;
template<class T> inline void print(T p) {
if(!p) { puts("0"); return; }
while(p) stk[++ tp] = p%10, p/=10;
while(tp) putchar(stk[tp--] + '0');
putchar('\n');
} //const LL mod=1e9+7;
const double PI=acos(-1.0);
const LL inf=1e18;
const int N=1e6+10;
const int maxn=1005;
const double eps=1e-10; char s[N],ans[N]; int main()
{
scanf("%s",s); int len=strlen(s),pos=len,lastpos,cnt;
For(i,0,len-1)
{
if(s[i]=='.')
{
pos=i;
break;
}
}
//if(s[0]=='.')pos=0;
For(i,0,len-1)
{
if(s[i]>'0'&&s[i]<='9')
{
ans[0]=s[i];
ans[1]='.';
lastpos=i+1;
cnt=1;
for(int j=i+1;j<len;j++)
{
if(s[j]>='0'&&s[j]<='9')ans[++cnt]=s[j];
}
break;
}
}
for(int i=cnt ;i>=1;i--)
{
if(ans[i]=='0'||ans[i]=='.')cnt--;
else break;
}
for(int i=0;i<=cnt;i++)
{
printf("%c",ans[i]);
}
if(pos!=lastpos)
{
if(pos>lastpos)
{
printf("E%d",pos-lastpos);
}
else
{
printf("E%d",pos-lastpos+1);
}
}
printf("\n");
return 0;
}

  

codeforces 691C C. Exponential notation(科学计数法)的更多相关文章

  1. Educational Codeforces Round 14 C. Exponential notation 数字转科学计数法

    C. Exponential notation 题目连接: http://www.codeforces.com/contest/691/problem/C Description You are gi ...

  2. PAT 甲级 1073 Scientific Notation (20 分) (根据科学计数法写出数)

    1073 Scientific Notation (20 分)   Scientific notation is the way that scientists easily handle very ...

  3. PAT Basic 1024 科学计数法 (20 分) Advanced 1073 Scientific Notation (20 分)

    科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [+-][1-9].[0-9]+E[+-][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指 ...

  4. 【转】js 中导出excel 较长数字串会变为科学计数法

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

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

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

  6. js 中导出excel 较长数字串会变成科学计数法

    在做项目中,碰到如题的问题.比如要将居民的信息导出到excel中,居民的身份证号码因为长度过长(大于10位),excel会自动的将过长的数字串转换成 科学计数法.现在网上找到解决方案之一: (在数字串 ...

  7. js导出excel表格中较长数字串会变成科学计数法问题

    在做项目中,遇到导出excel表格时,银行账户号数字过长,导出的数字串变为计数法形式,如下图: 网上搜到解决方法,粘贴到这以供学习.不断更新. 原博地址:http://www.cnblogs.com/ ...

  8. js 中导出excel 较长数字串会变成科学计数法(转载)

    在做项目中,碰到如题的问题.比如要将居民的信息导出到excel中,居民的身份证号码因为长度过长(大于10位),excel会自动的将过长的数字串转换成 科学计数法.现在网上找到解决方案之一: (在数字串 ...

  9. csv 中 数值被自动转换成科学计数法 的问题 excel打开后数字用科学计数法显示且低位变0的解决方法

    保存在csv中的 013812345678,前面的0会被去掉,后面是科学计数法显示.保存成 col1,="013812345678" 即可. 注意,分隔符逗号后面直接接“=”等号. ...

随机推荐

  1. 51 NOD 1325 两棵树的问题

    Discription 对于 100% 的数据, N<=50. solution: 发现N比较小,所以我们可以花O(N^2)的代价枚举两颗树的联通块的LCA分别是哪个点,然后现在问题就变成了:选 ...

  2. nginx原配置

    #原配置 server { listen ; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main ...

  3. qq空间微博等更多社交平台分享

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>& ...

  4. 用JS过滤Emoji表情的输入

    本文为原创,转载请注明出处: cnzt       文章:cnzt-p http://www.cnblogs.com/zt-blog/p/6773854.html 在前端页面开发过程中,总会碰到不允许 ...

  5. http://www.yiibai.com/java8/java8_temporaladjusters.html

    原文:http://www.yiibai.com/java8/java8_temporaladjusters.html TemporalAdjuster 是做日期数学计算.例如,要获得“本月第二个星期 ...

  6. Docker 的CMD与ENTRYPOINT区别

    我们在构建一个docker镜像的时候,Dockerfile里面有两个命令会引起我们的注意,它们就是 CMD 和 ENTRYPOINT,看起来很相似,实际上并非如此. 一.CMD 顾名思义就是允许用户指 ...

  7. Go -- 漫谈IM通信架构

    前前后后做的IM和推送系统已经有好几个了,一直都想好好总结下,因此就有了这篇文章.在我刚学编程的那会儿,觉得网络通信是一个很牛逼和门槛很高的一门技术,但是随着开源技术的发展和互联网知识的共享,现在要写 ...

  8. Python机器学习--聚类

    K-means聚类算法 测试: # -*- coding: utf-8 -*- """ Created on Thu Aug 31 10:59:20 2017 @auth ...

  9. 数据库官方在线文档列表(mysql, postgreSQL)

    1. mysql http://dev.mysql.com/doc/ 2. postgreSQL https://www.postgresql.org/docs/

  10. 具体解释window.history

    Window.history保存用户在一个会话期间的站点訪问记录,用户每次訪问一个新的URL即创建一个新的历史记录. history.go().history.back().history.forwa ...