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.

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,用三个变量来记录第一个不为0的数的位置,小数点的位置,最后一个不为0的数的位置,用这三个量来进行判断,首先是无论哪种情况,第一个数都是直接输出的,之后根据具体情况来确定小数点是不是输出,只有一位的时候就不用输出小数点了,之后再输出小数点后的位数,最后一步是判断E的值,这里需要根据小数点的位置来判断,如果小数点在第一个不为0的数后面,此时E的值为tar2-tar1-1,其余时候为tar2-tar1,如果这个值为0就不要输出。把模拟的细节处理好,还是比较容易的。

AC代码

#include<iostream>
#include<stdio.h>
using namespace std;
string num;
string ans;
int main()
{cin>>num;int flag=1;int tar1=-1,tar2=num.length(),tar3=-1; for(int i=0;i<num.length();i++){if(flag==1&&num[i]!='0'&&num[i]!='.'){flag=0;tar1=i;}if(num[i]=='.')tar2=i;if(num[i]!='0'&&num[i]!='.')tar3=i;}if(tar1==-1) cout<<"0"<<endl;else{cout<<num[tar1];if(tar3>tar1)cout<<".";for(int i=tar1+1;i<=tar3;i++)if(num[i]!='.')cout<<num[i];int temp;if(tar1<tar2)temp=tar2-tar1-1;else temp=tar2-tar1;if(temp!=0)printf("E%d\n",temp);elsecout<<endl;}return 0;
}

Exponential notation 思维题相关推荐

  1. CF-697B Barnicle与691C Exponential notation

    无聊写两个题解吧,上午做比赛拉的,感触很多! B. Barnicle time limit per test 1 second memory limit per test 256 megabytes ...

  2. little w and Soda(思维题)

    链接:https://ac.nowcoder.com/acm/contest/297/A 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言5242 ...

  3. ZOJ 3829 贪心 思维题

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3829 现场做这道题的时候,感觉是思维题.自己智商不够.不敢搞,想着队友智商 ...

  4. yoyo思维题(困难) 组合数学

    问题 B: yoyo思维题(困难) 时间限制: 1 Sec  内存限制: 256 MB 提交: 11  解决: 3 [提交][状态][讨论版][命题人:qianyouyou][Edit] [TestD ...

  5. 1884: 三个家庭(思维题)

    1884: 三个家庭 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 244 Solved: 81 [Submit][Status][Web Board] ...

  6. 思维题 UVA 10881 Piotr's Ants

    题目传送门 1 /* 2 题意:在坐标轴上一群蚂蚁向左或向右爬,问经过ts后,蚂蚁的位置和状态 3 思维题:本题的关键1:蚂蚁相撞看作是对穿过去,那么只要判断谁是谁就可以了 4 关键2:蚂蚁的相对位置 ...

  7. CF--思维练习-- CodeForces - 215C - Crosses(思维题)

    ACM思维题训练集合 There is a board with a grid consisting of n rows and m columns, the rows are numbered fr ...

  8. ACM思维题训练 Section A

    题目地址: 选题为入门的Codeforce div2/div1的C题和D题. 题解: A:CF思维联系–CodeForces -214C (拓扑排序+思维+贪心) B:CF–思维练习-- CodeFo ...

  9. CodeForces - 1102A(思维题)

    https://vjudge.net/problem/2135388/origin Describe You are given an integer sequence 1,2,-,n. You ha ...

最新文章

  1. 有关YARN/MRv2 相关
  2. Silverlight+WCF 实战-网络象棋最终篇之对战视频-下篇[客户端发送与服务端中转](六)...
  3. 【Android工具】Yandex!可以安装PCchrome插件的手机浏览器!更新网页剪辑插件测试情况...
  4. 再获IDC认可 第四范式持续扩大中国机器学习平台市场领先优势
  5. BZOJ1558 等差数列
  6. ascii modbus vc源码_MODBUS ASCII及MODBUS RTU通讯
  7. java自定义注解学习笔记
  8. 腾讯云实验之搭建 GIT 服务器教程
  9. Oracle动态执行表不可访问解决方法
  10. JS简单实现分页显示
  11. ckplayer6.8修改logo
  12. matlab绘制三维图形,Matlab 应用之绘制三维图形(基础篇)(组图)
  13. 【流媒体开发】【数据与封装格式】20、AAC码流格式与解析
  14. H3C设备查看信息命令
  15. 心法利器[53] | 数据增强的现实应用思考
  16. 北京师范大学新闻与传播专硕考研一战上岸经验分享
  17. 【LeetCode 1220】 Count Vowels Permutation
  18. 陀螺精选第1期:BCH生死战,谁能存活?
  19. WCF的服务部署方法
  20. CAPM1:有效市场假说

热门文章

  1. 统计每天的数据 无数据也要显示日期程序解决方法
  2. CF 55D Beautiful numbers 数位DP
  3. 关于字符串匹配算法研究
  4. Oracle中针对层次数据所设计的专用SQL查询语句
  5. MIG IP学习笔记
  6. crypto在web的使用
  7. 在QT中使用同步阻塞式HTTP请求的方法
  8. Python一行代码
  9. shell命令locate
  10. 【Java从0到架构师】Maven