【模拟】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 /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
随机推荐
- Android 使用弹出对话框,报Unable to add window错误
今天在使用Android弹出对话框的时候,报了一个unable to add window错误,我的代码如下 new AlertDialog.Builder(getApplicationContext ...
- 实现多个ContentProvider对多张表进行操作
http://blog.csdn.net/maylian7700/article/details/7365373 SQLite数据库直接操作类: DatabaseHelper.java package ...
- 关于百度 UEditor的使用
1.文件路径的配置: 注意:在页面上需要指定editor文件所在的路径,否则报错 后面有时间,再说说 kindEditor和 bootstrap3的summernote的 Editor, fck ...
- 图论——读书笔记(基于BFS广度优先算法的广度优先树)
广度优先树 对于一个图G=(V,E)在跑过BFS算法的过程中会创建一棵广度优先树. 形式化一点的表示该广度 优先树的形成过程是这样的: 对于图G=(V,E)是有向图或是无向图, 和图中的源结点s, 我 ...
- Ubuntu系统配置日志/var/log/message
ubuntu系统默认不生成/var/log/messages文件,有时候想查看相关日志就很不方便,于是我们可以设置使系统生成此文件. 1.先安装 apt-get install rsyslog2.用v ...
- ORACLE用户管理方式下备份数据和复制数据库
首先要明确的是,oracle数据库的备份可以分为逻辑备份和物理备份. 逻辑备份的是通过数据导出对数据进行备份,主要方式有老式的IMP/EXP和数据泵灯方式.适合变化较少的数据库,而 ...
- 【转】 NSString什么时候用copy,什么时候用strong
原文: http://blog.csdn.net/itianyi/article/details/9018567 大部分的时候NSString的属性都是copy,那copy与strong的情况下到底有 ...
- iOS支付 IPAPayment demo iTunes Conection里面添加测试帐号,添加商品,实现购买过程
https://github.com/ccguo/IAPPaymentDemo 发一个demo
- Mysql group_concat函数被截断的问题
mysql group_concat函数被截断的问题 MySQL的 group_concat 函数默认返回1024个字节长度,超过长度的会被截断.最近程序中就遇到这个问题了. 通过如下命令可以查看 ...
- cocod2d-x 之 HelloWorld
cocos2d-x 2.2创建项目 进入cocos2d-x-2.2/tools/project-creator,运行命令 python create_project.py -project MyGam ...