Codeforces 691C. Exponential notation 模拟题
2 seconds
standard input
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.
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.
Print the only line — the "simple exponential notation" of the given number x.
16
1.6E1
01.23400
1.234
.100
1E-1
100.
1E2 题目链接:http://codeforces.com/problemset/problem/691/C
题意:就是把一个数转换成a*10^b(1≤a﹤10)形式,输出aEb。
思路:标记第一个不为零的数的位置作为起点s,标记最后一个不为零的数的位置作为终点e,标记小数点的位置sign,默认位置应该为len+1。根据三个位置进行输出。 代码:
#include<bits/stdc++.h>
using namespace std;
char x[];
int main()
{
int i;
scanf("%s",x);
int len=strlen(x);
int s=-,e=len-,sign=len;
for(i=; i<len; i++)
if(x[i]=='.')
{
sign=i;
break;
}
for(i=; i<len; i++)
if(x[i]>''&&x[i]<='')
{
s=i;
break;
}
for(i=len-; i>=; i--)
if(x[i]>''&&x[i]<='')
{
e=i;
break;
}
if(s>=)
{
cout<<x[s];
if(e>s) cout<<".";
for(i=s+; i<=e; i++)
if(x[i]!='.') cout<<x[i];
if((s+)!=sign)
{
cout<<"E";
if(s<sign) cout<<sign-s-<<endl;
else if(s>sign) cout<<sign-s<<endl;
}
}
else cout<<""<<endl;
return ;
}
Codeforces 691C. Exponential notation 模拟题的更多相关文章
- 【模拟】Codeforces 691C Exponential notation
题目链接: http://codeforces.com/problemset/problem/691/C 题目大意: 输入一个数,把它表示成a·10b形式(aEb).输出aEb,1<=a< ...
- Codeforces 691C. Exponential notation
题目链接:http://codeforces.com/problemset/problem/691/C 题意: 给你一个浮点数,让你把这个数转化为 aEb 的形式,含义为 a * 10b, 其中 a ...
- Codeforces 767B. The Queue 模拟题
B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...
- CF-697B Barnicle与691C Exponential notation
无聊写两个题解吧,上午做比赛拉的,感触很多! B. Barnicle time limit per test 1 second memory limit per test 256 megabytes ...
- CodeForces - 344B Simple Molecules (模拟题)
CodeForces - 344B id=46665" style="color:blue; text-decoration:none">Simple Molecu ...
- CodeForces - 344D Alternating Current (模拟题)
id=46667" style="color:blue; text-decoration:none">CodeForces - 344D id=46667" ...
- CodeForces - 344E Read Time (模拟题 + 二分法)
E. Read Time time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- CodeForces 681C Heap Operations (模拟题,优先队列)
题意:给定 n 个按顺序的命令,但是可能有的命令不全,让你补全所有的命令,并且要求让总数最少. 析:没什么好说的,直接用优先队列模拟就行,insert,直接放入就行了,removeMin,就得判断一下 ...
- codeforces 691C C. Exponential notation(科学计数法)
题目链接: C. Exponential notation time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
随机推荐
- android提权
Android的内核就是Linux,所以Android获取root其实和Linux获取root权限是一回事儿. 你 想在Linux下获取root权限的时候就是执行sudo或者su,接下来系统会提示你输 ...
- 关于pthreads的使用
产品想实现PHP端的多线程下载 百度了下找到了一个方法,通常需要开启PHP线程安全策略,就是 编译安装的时候 --enable-maintainer-zts 然后安装pthreads扩展, 但是pt ...
- Nop权限的使用
1.首先后台Admin--->siteMap中添加: <siteMapNode SystemName="我是系统名" nopResource="显示的中文名称 ...
- PY3 周总结 第一周
1. Python的三大特点是什么? 答:解释型.动态类型(运行期间才做数据类型检查).强类型定义(一个变量只能存储一种类型的数据).[See More] 2. 应该使用Python2 还是 Pyth ...
- cobller安装操作系统
参考网站:https://blog.csdn.net/admin_root1/article/details/78911718 https://www.cnblogs.com/panwenbin-lo ...
- css属性 writing-mode 改变文字书写方向
作为IE的私有属性之一,IE5.5率先实现了 writing-mode ,后期被w3c采纳成标准属性: #test{ -webkit-writing-mode: vertical-rl;/*horiz ...
- RAD 10 C++Builder的bug
C++Builder的bug 修改一行代码,F9会报错.要clear工程重新完整编译才可以. 新建空白工程是好的. restart computer ok!!! 2)fdquery like this ...
- WDA-FPM-3-SEARCH(OIF)
转载:https://www.cnblogs.com/sapSB/p/10097830.html FPM三:简单的SEARCH(OIF) 这里是使用FPM Workbench自动生成的,没有去SE ...
- Java时间操作常用api
- 如何取得年月日.小时分钟秒?- 如何取得从1970年1月1日0时0分0秒到现在的毫秒数?- 如何取得某月的最后一天?- 如何格式化日期?答:问题1:创建java.util.Calendar 实例, ...
- 工作中用到和应该知道的eclipse快捷键
Eclipse最初是由IBM公司开发的替代商业软件Visual Age for Java的下一代IDE开发环境,2001年11月贡献给开源社区,现在它由非营利软件供应商联盟Eclipse基金会(Ecl ...