【模拟】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 /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...
随机推荐
- webservice 发布到外网的时候
在web.config的<system.web></system.web>中间加入如下配置节内容<webServices> <protoco ...
- jQuery作用
jquery是前端里面比较总要的,是很强大的一个选择器. 表单: 1.$(":input") 查找所有的input元素 2.$("text") 匹配所有的 ...
- Log4j简单配置
Log4j是一组强大的日志组件,在项目中时常需要用它提供一些信息,这两天学习了一下它的简单配置. 第一步,我们需要导入log4j-1.2.14.jar到lib目录下 第二步,在src下建立log4j. ...
- C# List
命名空间:using System.Collections; class Program {//做个比较 static void Main(string[] args) { //new对象 Cls a ...
- 异常练习一 throw
package 异常练习;class OutageroudleException extends RuntimeException{ OutageroudleException(){ } Outage ...
- 64位 CentOS NDK 编译 FFMPEG
64位 CentOS NDK 编译 FFMPEG 一. 参考文章: http://www.cnblogs.com/baopu/p/4733029.html http://www.c ...
- QWidget QMainWindow QDialog 三者区别
Qt类是一个提供所需的像全局变量一样的大量不同的标识符的命名空间.通常情况下,你可以忽略这个类.QObject和一些其它类继承了它,所以在这个Qt命名空间中定义的所有标识符通常情况下都可以无限制的使用 ...
- LA 6856 Circle of digits 解题报告
题目链接 先用后缀数组给串排好序.dc3 O(n) 二分答案+贪心check 答案的长度len=(n+k-1)/k 如果起点为i长为len串大于当前枚举的答案,i的长度取len-1 从起点判断k个串的 ...
- 【POJ1823】【线段树】Hotel
Description The "Informatics" hotel is one of the most luxurious hotels from Galaciuc. A l ...
- javascript——面向对象程序设计(1)
<script type="text/javascript"> //ECMA-262把对象定义为:“无序属性的 集合,其属性可以包含基本值.对象或者函数” //理解对象 ...