Codeforces Round #362 (Div. 2) B 模拟
1 second
256 megabytes
standard input
standard output
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 题意:x = A × 10B 将科学计数法 转为为普通实数 不能有前导零 不能有后置零
hack数据
0.0e0
0
2.40000e2
240 题解:模拟 注重细节处理 考虑要细致
#include<bits/stdc++.h>
#define ll __int64
#define mod 1e9+7
#define PI acos(-1.0)
#define bug(x) printf("%%%%%%%%%%%%%",x);
using namespace std;
char a[];
char b[];
int main()
{
cin>>a;
int len=strlen(a);
int wei=;
int flag;
for(int i=;i<len;i++)//找到小数点
{
if(a[i]=='.')
flag=i;
}
int gg=;
int zha=;
for(int j=len-;j>flag;j--)//进多少位
{
if(a[j]=='e')
{
a[j]='\0';
break;
}
wei=wei+(a[j]-'')*gg;
gg*=;
a[j]='\0';
} len=strlen(a);
int weishu=len-(flag+);//现有小数位数
if(wei==&&weishu==&&a[]=='')//特判数据
{
cout<<a[]<<endl;
return ;
}
if(wei<weishu)
{
for(int j=flag;j<flag+wei;j++)
a[j]=a[j+];
a[flag+wei]='.';
}
if(wei==weishu)
{
for(int j=flag;j<flag+wei;j++)
a[j]=a[j+];
a[flag+wei]='\0';
}
if(wei>weishu)
{
for(int j=flag;j<flag+weishu;j++)
a[j]=a[j+];
for(int j=flag+weishu;j<flag+wei;j++)
a[j]='';
a[flag+wei]='\0';
}
int len1=strlen(a);
int aaa=;
int zzz=;
if(wei<weishu)//去掉后置零
{
for(int j=len1-;j>;j--)
{
if(zzz)
break;
if(a[j]!='')
zzz=;
if(a[j]==''||a[j]=='.')
a[j]='\0'; }
}
for(int i=;i<len1;i++)//去掉前导零
{
if(a[i]!=''||a[i+]=='.')
aaa=;
if(aaa)
{
cout<<a[i];
}
}
cout<<endl;
return ;
}
Codeforces Round #362 (Div. 2) B 模拟的更多相关文章
- Codeforces Round #249 (Div. 2) (模拟)
C. Cardiogram time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Codeforces Round #366 (Div. 2) C 模拟queue
C. Thor time limit per test 2 seconds memory limit per test 256 megabytes input standard input outpu ...
- Codeforces Round #362 (Div. 2) C. Lorenzo Von Matterhorn (类似LCA)
题目链接:http://codeforces.com/problemset/problem/697/D 给你一个有规则的二叉树,大概有1e18个点. 有两种操作:1操作是将u到v上的路径加上w,2操作 ...
- #map+LCA# Codeforces Round #362 (Div. 2)-C. Lorenzo Von Matterhorn
2018-03-16 http://codeforces.com/problemset/problem/697/C C. Lorenzo Von Matterhorn time limit per t ...
- 题解——Codeforces Round #508 (Div. 2) T1 (模拟)
依照题意暴力模拟即可A掉 #include <cstdio> #include <algorithm> #include <cstring> #include &l ...
- Codeforces Round #281 (Div. 2) B 模拟
B. Vasya and Wrestling time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Codeforces Round #281 (Div. 2) A 模拟
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 【转载】【树形DP】【数学期望】Codeforces Round #362 (Div. 2) D.Puzzles
期望计算的套路: 1.定义:算出所有测试值的和,除以测试次数. 2.定义:算出所有值出现的概率与其乘积之和. 3.用前一步的期望,加上两者的期望距离,递推出来. 题意: 一个树,dfs遍历子树的顺序是 ...
- 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 ...
随机推荐
- 题解 P4613 【[COCI2017-2018#5] Olivander】
话说这道题,作为一个哈迷,是不能错过的 我很惊讶本蒟蒻竟然看得懂题面 好了,闲话少说,这道题,虽说是入门难度,但凭着良心说,它还是一道普及 - 的吧 看到标签,“高性能”,大脑的第一反应是快读. 是不 ...
- java编程基础——从上往下打印二叉树
题目描述 从上往下打印出二叉树的每个节点,同层节点从左至右打印. 题目代码 /** * 从上往下打印出二叉树的每个节点,同层节点从左至右打印. * Created by YuKai Fan on 20 ...
- c#基础之循环探索
前言在学习基础的语法中循环控制是程序语句控制中的一种,循环在很多的操作中都有应用,例如在获得数据库中的查询的数据之后可以用循环遍历的方式拿到每一行的数据,从而拿到每一个单元格的数据,在文件的操作中也大 ...
- elasticsearch 7 安装
elasticsearch 安装 操作系统:CentOS Linux release 7.4 elasticsearch:elasticsearch-7.1.1 es7+centos7 1.软件下载 ...
- pm2 服务器命令
1..配置日志文件路径 命令:pm2 start /home/admin/node/fotonIp/bin/www --name ip -i 4 -o "/app/node/logs ...
- mysql基础,数据表的类型
- 获取页面URL参数值
JavaScript function GetParams(urlAddress) { var i, strLength, str, keyName, keyValue, params = {}, u ...
- 【工具】Sublime Text 自动保存功能
经常需要所以要频繁用到"ctrl+s"保存还是挺麻烦的,所以有的人需要用到失去焦点自动保存功能,这里简单记录下 1.点击"Preferences"里的设置-用户 ...
- 记忆化搜索:POJ1579-Function Run Fun(最基础的记忆化搜索)
Function Run Fun Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 14815 Accepted: 7659 Des ...
- 模拟:HDU1034-Candy Sharing Game
解题心得: 1.直接模拟每一次分一半就行了,模拟过程,记录轮数,但是也看到有些大神使用的是链表,估计链表才是真的做法吧. 题目: Candy Sharing Game Time Limit: 2000 ...