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 ...
随机推荐
- 更换PostgreSql的data文件夹并重新服务器(此方法同样适用于系统崩溃后,找回数据的操作)
*如果是系统崩溃,需要找回数据,PostgreSQL安装目录的data文件夹要存在 1.备份PostgreSQL安装目录到其他目录下 2.停止Postgres服务,可以在运行中输入services.m ...
- 最近面试前端岗位,汇总了一下前端面试题(JS+CSS)
JavaScript 运行机制 1. 单线程(用途决定,需要与用户互动以及操作DOM) 2. 分同步任务(主线程)与异步任务(任务队列),只有任务队列通知主线程某个任务可以执行了,该 任务才会进入主线 ...
- python Scraping
http://docs.python-guide.org/en/latest/scenarios/scrape/
- JS - Array.slice 与 Array.splice
1)Array.slice方法 1.1)接收两个参数: a:起始下标 b:结束下标 1.2)返回由a(包括)至b(不包括)的元素所组成的数组 ...
- 【Django】Django开发中的日志输出
开发环境:Ubuntu16.04+Django 1.11.9+Python2.7 一:使用自定义函数输出日志到log文件: import time def print_log(log): file_o ...
- 将xml转为array 输出xml字符
//将xml转为array private function fromXml($xml){ // 禁止引用外部xml实体 libxml_disable_entity_loader(true); ret ...
- JZOJ 5777. 【NOIP2008模拟】小x玩游戏
5777. [NOIP2008模拟]小x玩游戏 (File IO): input:game.in output:game.out Time Limits: 1000 ms Memory Limits ...
- django admin模块使用
BBS之admin组件的使用 1.创建超级管理员 创建超级管理员 一. tools>>>>runmanagepyTask>>>>>createsu ...
- C#开发模式——dll多级引用的问题
C#解决方案里有两种引用方式,项目引用和dll物理文件引用. 一.项目引用 严格引用,项目文件需包含在解决方案里,好处是便于调试,可直接进入代码.缺点是耦合度太高(必须全部编译通过才能run起来),项 ...
- WPF学习笔记(8):DataGrid单元格数字为空时避免验证问题的解决
原文:WPF学习笔记(8):DataGrid单元格数字为空时避免验证问题的解决 如下图,在凭证编辑窗体中,有的单元格不需要数字,但如果录入数字后再删除,会触发数字验证,单元格显示红色框线,导致不能执行 ...