题目链接: 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. 《利用python进行数据分析》读书笔记--第四章 numpy基础:数组和矢量计算

    http://www.cnblogs.com/batteryhp/p/5000104.html 第四章 Numpy基础:数组和矢量计算 第一部分:numpy的ndarray:一种多维数组对象 实话说, ...

  2. Zabbix3.x安装图解教程

    准备知识: Zabbix3.x比较之前的2.0界面有了很大的变化,但是安装部署过程与2.x基本完全一样. 1.Zabbix2.x安装图解教程 http://www.osyunwei.com/archi ...

  3. reverseajax(comet) socket 杂记

    http://blog.it985.com/7797.html http://www.ibm.com/developerworks/web/library/wa-reverseajax1/index. ...

  4. DbContext 那些事 —— 数据库初始化

    数据库初始化 上图,这个图解释了,数据库初始化的流程,是基于我们在上下文类中的构造函数中传递的参数. 在上面的图中,context类中的base构造器中,可以填入下面的参数: 无参数(No Param ...

  5. Exception in thread "main" java.lang.ExceptionInInitializerError

    Exception in thread "main" java.lang.ExceptionInInitializerErrorCaused by: java.util.Missi ...

  6. Linux时间设置及同步

    Linux系统安装时选择的UTC时间是国际标准时间,而中国处于UTC+8时区,因此安装系统时不要选择UTC时区. 还有就是Linux有两个时钟: 1.Bios时钟及硬件时间 2.Kernel时钟及系统 ...

  7. C# 利用NPOI 实现Excel转html

    public void ExcelToHtml(string fileName, IWorkbook workbook) { ExcelToHtmlConverter excelToHtmlConve ...

  8. C# 发送qq邮箱

    注意: QQ邮箱的简单邮件传输协议(SMTP)使用了SSL加密,必须启用SSL加密.指定端口. QQ邮箱POP3/SMTP服务默认是关闭的,需要开启服务(设置=>账户=>开启服务). QQ ...

  9. plist基本操作

    重要概念:某些路径下“只能读,不能写”的原因 iPhone.ipad真机上 Resouces文件夹:是只读的,无法写入. document 和temp文件夹:可读,可写. 一.工程结构

  10. 撤销git reset soft head操作

    一不小心在eclipse的git库中执行了Reset Soft(HEAD ONLY)操作,不料界面中竟然没有找到撤销方法(于是心中五味俱全,经过一番折腾,无果还是回归Git本身),最终通过命令行,很快 ...