Barnicle
Barnicle
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A × 10B is true. In our case A is between 0 and 9 and B is non-negative.
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 ≤ a ≤ 9, 0 ≤ d < 10100, 0 ≤ b ≤ 100) — the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
8.549e2
854.9
8.549e3
8549
0.33e0
0.33
分析:注意0.0e0;
代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <ext/rope>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define vi vector<int>
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
const int maxn=1e5+;
const int dis[][]={{,},{-,},{,-},{,}};
using namespace std;
using namespace __gnu_cxx;
ll gcd(ll p,ll q){return q==?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=;while(q){if(q&)f=f*p;p=p*p;q>>=;}return f;}
int n,m,now,len,cnt;
string a,ans;
int main()
{
int i,j,k,t;
cin>>a;
len=a.length(); //特判;
if(a=="0.0e0")return *puts(""); //找分隔符e;
for(now=;a[now]!='e';now++); //计算进位;
for(i=now+;i<len;i++)cnt=cnt*+a[i]-'';
ans+=a[]; //进位;
for(i=;i<cnt&&a[+i]!='e';i++)ans+=a[+i],now=+i; if(i!=cnt)for(;i<cnt;i++)ans+='';//不足补0;
else
{
ans+='.'; //小数部分;
for(;a[+i]!='e';i++)ans+=a[+i],now=+i;
} //处理答案前多余0;
for(i=;ans[i]=='';i++);
if(ans[i]=='.')i--;
ans.erase(,i); //处理小数点后末尾0;
len=ans.length();
if(count(ans.begin(),ans.end(),'.')!=)
{
len=ans.length();
for(i=len-;i>=&&(ans[i]==''||ans[i]=='.');i--);
ans=ans.substr(,i+);
}
cout<<ans<<endl;
//system ("pause");
return ;
}
Barnicle的更多相关文章
- CodeForces #362 div2 B. Barnicle
题目链接: B. Barnicle 题意:给出科学计数法 转化成十进制的整数或小数 并输出. 思路:暑假训练赛见过了,当时大腿A掉了,并表示是道水题. 刷CF再次遇见,毫不留情WA了几次.比如: 0. ...
- Codeforces Round #362 (Div. 2)->B. Barnicle
B. Barnicle time limit per test 1 second memory limit per test 256 megabytes input standard input ou ...
- Codeforces 679B. Barnicle 模拟
B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...
- CF-697B Barnicle与691C Exponential notation
无聊写两个题解吧,上午做比赛拉的,感触很多! B. Barnicle time limit per test 1 second memory limit per test 256 megabytes ...
- 【CodeForces 697B】Barnicle
对科学计数法表示的数,输出其10进制的形式. c++来做,需要考虑这些细节: 当b==0,d==0时,只输出a. 当不需要补零的情况有两种: 一种是刚好是整数,只输出a(注意1.0e1的情况是输出1) ...
- codeforces 697B Barnicle
题目链接:http://codeforces.com/problemset/problem/697/B 题目大意: 将科学计数法用十进制表示.[如果类似于7.0应输出7] 解题思路: Java 中 B ...
- CodeForces 697B Barnicle 模拟
强行模拟 纪念一下…… #include<stdio.h> #include<iostream> #include<algorithm> #include<m ...
- Codeforces Round #362 (Div. 2) A.B.C
A. Pineapple Incident time limit per test 1 second memory limit per test 256 megabytes input standar ...
- Codeforces Round #362
A - Pineapple Incident #pragma comment(linker, "/STACK:102c000000,102c000000") #include &l ...
随机推荐
- CRC的校验原理
一.基本原理 CRC检验原理实际上就是在一个p位二进制数据序列之后附加一个r位二进制检验码(序列),从而构成一个总长为n=p+r位的二进制序列:附加在数据序列之后的这个检验码与数据序列的内容之间存在着 ...
- 【读书笔记】Linux源码注释
第二章 大概的内部组成 IO端口寻址: 统一寻址: 就是把地址归入存储器寻址范围. 独立寻址: 跟存储器分开,专门的寻址空间 没怎么理解, PC机一般都是采用独立寻址, 见下图 在linux里,可以在 ...
- Java静态语句块、语句块、构造方法执行顺序
package com.imooc.practice; class Parent{ public Parent(){ System.out.println("Parent构造方法执行!&qu ...
- hdu_5676_ztr loves lucky numbers
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5676 在这%一下安神,用了我没见过的黑科技next_permutation,至少我是今天才知道的 #i ...
- 手机版WEB开发经验分享,手机版网站开发注意事项,网站自适应,手机版网站自适应,移动安卓APP自适应
转自 http://my.oschina.net/cart/blog/282477 做前端开发不短了,用过jQuery Mobile jqMobi 也纯手工写过.. 最后总结如下: jQuery Mo ...
- java问题诊断
http://techblog.youdao.com/?p=961 http://linuxtools-rst.readthedocs.org/zh_CN/latest/advance/03_opti ...
- 使用HAXM加速Android虚拟机
Android虚拟机在支持Intel VT技术的CPU上,可以使用HAXM(Hardware Accelerated Execution Manager)得到硬件加速支持,使得虚拟机运行速度得到极大提 ...
- 给postgresql 创建新的用户
\du 查看当前postgresql的用户,一般此时只能看到 postgres create user ysr superuser password '123456'; \du 就可以看到两个用户了. ...
- bios自检时间长,显示0075错误
一amibios主板,只有一IDE接口,接一硬盘一光驱,每次启动时,在bios自检界面,在检测完usb设备后,都要等个那么一两分钟,这个时候,可以在屏幕的右下角看到有数字:0075 ,这就是错误代码. ...
- A*算法实现
A* 算法非常简单.算法维护两个集合:OPEN 集和 CLOSED 集.OPEN 集包含待检测节点.初始状态,OPEN集仅包含一个元素:开始位置.CLOSED集包含已检测节点.初始状态,CLOSED集 ...