【模拟】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 /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
随机推荐
- js request
比如你要获取aaa.aspx?id=2 使用方法为:var id= request('id');
- CentOS安装最新的Mysql版本
Step1: 检测系统是否自带安装mysql # yum list installed | grep mysql Step2: 删除系统自带的mysql及其依赖命令: # yum -y remove ...
- 原生JS+tween.js模仿微博发布效果
转载请注明出处:http://www.cnblogs.com/zhangmingze/p/4816865.html 1.先看效果吧,有效果才有动力: 2.html结构: <!DOCTYPE ht ...
- sqlserver 时间转换
sql server2000中使用convert来取得datetime数据类型样式(全) 日期数据格式的处理,两个示例: CONVERT(varchar(), 时间一, ) 结果:-- :/*时间一般 ...
- PetaPoco 增删改查
1 查询单行 DBInstance.DB.SingleOrDefault<CompanyInfo11>(id); /// <summary> /// 根据id获取公司信息 // ...
- SQL server抽疯后修改sa密码无法成功的处理办法
今天上班打开电脑,发现尼玛所有项目启动后都报错,原因是说数据库sa的验证错误,无法进行数据库链接等等东西,简单地说---SQL server抽疯了!!!:( 昨天还好好的.而且没有修改过东西.为啥会出 ...
- Jquery 替换全部花括号
js:var str="{aaa}123{aaa}";str.replace(/\{aaa\}/g, "111");
- java String对象的创建(jvm).
本人目前也开始学习虚拟机,在java中,有很多种类型的虚拟机,其中就以sum公司(当然现在已经是oracle了)的虚拟机为例,介绍可能在面试的时候用到的,同时对自己了解String有很大帮助,这里仅仅 ...
- winows8.1或winows7 64bit 安装Itunes 64bit 11.1.3 无法打开一直停止工作的解决办法
winows8.1或winows7 64bit 安装Itunes 64bit 11.1.3 无法打开一直停止工作的解决办法 系统环境变量里的Path追加 ;C:\program files (x86) ...
- javascript基础学习(六)
javascript之对象 学习要点: 对象的属性和方法 对象的原型 一.对象 对象其实就是一种引用类型,而对象的值就是引用对象的实例. 二.创建对象 在javascript中有两种对象,一种是系统内 ...