题目链接: B. Barnicle

题意:给出科学计数法 转化成十进制的整数或小数 并输出。

思路:暑假训练赛见过了,当时大腿A掉了,并表示是道水题。

   刷CF再次遇见,毫不留情WA了几次。比如:

0.e0       0

1.0e0     1

   突然觉得自己不能再依赖CF这种看着sample dbug的模式了。

附代码:

/// 给出科学计数法 转化成十进制的整数或小数 并输出

#include <stdio.h>
#include <string.h>
#include <iostream>
using namespace std; string str; int main() {
//freopen("in.cpp", "r", stdin);
while(cin >> str) {
string ans = "";
int len = str.length();
int lose;
for (int i=len-1; i>=0; --i) {
if (str[i] == 'e') {
lose = i;
break;
}
} int a = str[0] - '0';
if (a == 0) {
int endd = 0;
for (int i=lose-1; i>=0; --i){
if (str[i] > '0' && str[i] <= '9') {
endd = i;
break;
}
}
str.resize(endd+1);
cout << str << endl;
continue;
} ans += str[0];
int b = 0;
for (int i=lose+1; i<len; ++i) {
b = b*10 + str[i]-'0';
}
int cnt1 = 0;
bool first = false; //
for (int i=2; i<lose; ++i) {
if (cnt1 < b) {
ans += str[i];
}
else {
if (first == false) {
first = true;
ans += '.';
}
ans += str[i];
}
cnt1++;
}
while(cnt1 < b) {
ans += '0';
cnt1++;
}
if (ans[1] == '.') {
int anslen = ans.length();
bool ok = false;
for (int i=2; i<anslen; ++i) {
if (ans[i] > '0' && ans[i] <= '9') {
ok = true;
break;
}
}
if (!ok) ans.resize(1);
}
cout << ans << endl;
}
return 0;
}

CodeForces #362 div2 B. Barnicle的更多相关文章

  1. Codeforces #180 div2 C Parity Game

    // Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...

  2. Codeforces #541 (Div2) - E. String Multiplication(动态规划)

    Problem   Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...

  3. Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)

    Problem   Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...

  4. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  5. Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)

    Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...

  6. 【Codeforces #312 div2 A】Lala Land and Apple Trees

    # [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...

  7. Codeforces #263 div2 解题报告

    比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...

  8. codeforces #round363 div2.C-Vacations (DP)

    题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...

  9. codeforces round367 div2.C (DP)

    题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; ...

随机推荐

  1. 表单 阻止 技巧 JavaScript js

    阻止表单的提交,可以用return false 来进行阻止 长度不低于6,不高于20 if(username.length < 6 || username>20){ alert (&quo ...

  2. python 学习笔记十五 web框架

    python Web程序 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. Python的WEB框架分为两类: 自己写socket,自 ...

  3. spark使用02

    1.rdd的初始化 1.1 读取文件来初始化rdd(通过sparkContext的textFile方法) 1.1.1 读取本地文件 SparkConf conf = new SparkConf().s ...

  4. 求System.arraycopy的用法

    public class Shuzufuzhi { public static void main(String args[]) {  int myArray[]={1,2,3,4,5,6};  in ...

  5. GOLANG 变量

    语法格式 var    变量名    类型   类型:        可以是go语言内置的各种基本数据类型.复合数据类型,甚至是函数.方法.接口以及自定义类型. 声明变量会给变量设定零值.数值类型变量 ...

  6. IE11 HTML Help ActiveX

    <!--by: @qab--> <OBJECT id=HHCTRL type="application/x-oleobject" classid="cl ...

  7. 办公大楼3D指纹门禁系统解决方案

    随着人们对工作.生活的自动化水平也提出了越来越高的要求.以大楼安保对出入大楼的外来人员进行登记放行或以铁锁.钥匙和卡为代表的出入管理方式已无法满足需求. 利用科技的手段,实现办公大楼的安全现代化.管理 ...

  8. pip和easy_install更换使用国内源

    因为论文原因,需要使用python安装一些自然语言库,但是使用pip或easy_install安装包时,总是超时(中国特色搞得事:-D),没有办法,上网查资料解决问题~~,在网上找到的方法都是说更换国 ...

  9. js : json和 cookie 的简单操作

    使用 cookie,可以记录用户的最近的浏览历史 <!DOCTYPE HTML> <html lang="zh-cn"> <head> < ...

  10. A little bit about Handlers in JAX-WS

    by Rama Pulavarthi Handlers are message interceptors that can be easily plugged in to the JAX-WS run ...