【模拟】Codeforces 691C Exponential notation
题目链接:
http://codeforces.com/problemset/problem/691/C
题目大意:
输入一个数,把它表示成a·10b形式(aEb)。输出aEb,1<=a<10,b如果为1要省略Eb
题目思路:
【模拟】
如果字符串没有‘.'我就在最后加上一个'.'方便处理。
先把头尾多余的0去掉,然后把这个数按照'.'拆成两半,统计整数部分的位数zs。
接着统计'.'后面的0的个数xs,再把所有数字放到一个数组里,再把头多余的0去掉(0.0000xx)。
之后按照zs和sx的情况分类输出即可。注意细节。
//
//by coolxxx
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define mem(a,b) memset(a,b,sizeof(a))
#define eps (1e-8)
#define J 10
#define mod 1000000007
#define MAX 0x7f7f7f7f
#define PI 3.14159265358979323
#define N 1000004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
int zs,xs,e;
int a[N];
char s[N];
int main()
{
#ifndef ONLINE_JUDGE
// freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j,k;
int h,t,p;
// for(scanf("%d",&cass);cass;cass--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
while(~scanf("%s",s))
// while(~scanf("%d",&n))
{
n=strlen(s);mem(a,);
for(p=;p<n && s[p]!='.';p++);
if(p==n)s[n++]='.';
for(h=;h<n && s[h]=='';h++);
for(t=n-;t>= && s[t]=='';t--);
zs=p-h;
for(i=p+;i<t && s[i]=='';i++);
xs=i-p;
if(h==p && t==p){puts("");continue;}//0.0
for(i=t;i>=h;i--)
{
if(s[i]=='.')continue;
a[++a[]]=s[i]-'';
}
while(!a[a[]] && a[]>)a[]--;
printf("%d",a[a[]]);
for(j=;j<a[];j++)
if(a[j]!=)break;
if(a[]->=j)putchar('.');
for(i=a[]-;i>=j;i--)
printf("%d",a[i]);
if(zs>)
{
if(zs!=)printf("E%d\n",zs-);
}
else
{
printf("E%d\n",-xs);
}
puts("");
}
return ;
}
/*
// //
*/
【模拟】Codeforces 691C Exponential notation的更多相关文章
- Codeforces 691C. Exponential notation 模拟题
C. Exponential notation time limit per test: 2 seconds memory limit per test:256 megabytes input: st ...
- Codeforces 691C. Exponential notation
题目链接:http://codeforces.com/problemset/problem/691/C 题意: 给你一个浮点数,让你把这个数转化为 aEb 的形式,含义为 a * 10b, 其中 a ...
- CF-697B Barnicle与691C Exponential notation
无聊写两个题解吧,上午做比赛拉的,感触很多! B. Barnicle time limit per test 1 second memory limit per test 256 megabytes ...
- codeforces 691C C. Exponential notation(科学计数法)
题目链接: C. Exponential notation time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- Educational Codeforces Round 14 C. Exponential notation 数字转科学计数法
C. Exponential notation 题目连接: http://www.codeforces.com/contest/691/problem/C Description You are gi ...
- Exponential notation
Exponential notation You are given a positive decimal number x. Your task is to convert it to the &q ...
- 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts
题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...
- 模拟 Codeforces Round #203 (Div. 2) C. Bombs
题目地址:http://codeforces.com/problemset/problem/350/C /* 题意:机器人上下左右走路,把其他的机器人都干掉要几步,好吧我其实没读懂题目, 看着样例猜出 ...
- 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram
题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
随机推荐
- 绝对炫的幻灯片插件-SKITTER
绝对炫的幻灯片插件-SKITTER 所属分类:媒体-幻灯片和轮播图,图片展示,滑块和旋转 Includes code source // Styles <link href="css/ ...
- xpath 操作XML
1.xpath 操作XML,底下部分代码被注释了,但是是完整功能,去除注释是正常使用的(有写命名和其他冲突,所以注释了) 总体有:完整读取xml,对xml的增删改查,对xml的特定操作 using S ...
- android EventBus 的使用
今天简单的介绍 一下啊 android EventBus 的使用 EventBus 在官方介绍中是订阅......什么的 一大堆 , 在我android 菜鸟眼里 就是用来代替android 广 ...
- Uri、UriMatcher、ContentUris详解
http://blog.csdn.net/feng88724/article/details/6331396 1.Uri 通用资源标志符(Universal Resource Identifier, ...
- VsSharp:一个VS扩展开发框架(上)
上篇:设计 一.引子 自2008年起开发SSMS插件SqlSharp(er)的过程中,有一天发现多数代码都大同小异,就像这样. Commands2 commands = (Commands2)_app ...
- 解读oracle执行计划-待续
Cost(%CPU): 优化器估算出完成当前操作的代价(包含子操作的代价),它是IO代价和CPU 代价总和.其中IO代价是最基本的代价.而对于CPU代价,在默认情况下,优化器会将CPU代价计算在内,而 ...
- 浅析angular框架的cookie
相信接触过网页编程的基本上都知道cookie这个东西吧,一个毫不起眼,但是又十分的重要的东西,今天我们就来分析一下这个小东西,我们都知道客服端通过发送http请求到服务器请求我们的数据,当我们的服务器 ...
- c读写文件相关
1.打开文件: 函数原型: FILE * fopen(const char * path,const char * mode); 返回值: 文件顺利打开后,指向该流的文件指针就会被返回.如果文件打开失 ...
- laravel5.2学习资源
研究laravel的过程中基本把国内关于laravel的资料给翻了一遍了: 整理了一些中文的资源如下: 一:教程系列 1:https://laravist.com/series/laravel-5-b ...
- Android 动画效果 及 自定义动画
1. View动画-透明动画效果2. View动画-旋转动画效果3. View动画-移动动画效果4. View动画-缩放动画效果5. View动画-动画效果混合6. View动画-动画效果侦听7. 自 ...