题目链接: 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. AutoMagic

    AutoMagic 是一个基于WebUI的自动化管理平台.为什么叫AutoMagic呢?因为自动化(Automation)在执行起来的时候是一个很神奇的事情,它可以无人值守的模拟人的操作,就像魔术(M ...

  2. 闲的写写SQL

    /* 新增 */ Create Proc AddData ( ), ), @Values nvarchar(max) ) as declare @Sql nvarchar(max) declare @ ...

  3. 1.Dotnet Core安装

    DtnetCore1.0.1的安装包我以上传至百度网盘,里面有安装教程. http://pan.baidu.com/s/1c2iLNNE 如果安装不上,请留言,我会在第一时间回复你. 不需要挂VPN.

  4. a error of misunderstanding

    Last summer vacation, a classmate contacted with me and we finished a intelligent car project with i ...

  5. Google-GLog编译以及使用

    心血来潮要去看开源代码,看到公司的日志库是在google-glog开源库上二次封装的,那就先撸glog吧. 1. 下载源码  一条命令取源码:git clone github.com/google/g ...

  6. 1007. Maximum Subsequence Sum (25)

    Given a sequence of K integers { N1, N2, ..., NK }. A continuous subsequence is defined to be { Ni, ...

  7. 零配置文件搭建SpringMVC实践纪录

    本篇记录使用纯java代码搭建SpringMVC工程的实践,只是一个demo.再开始之前先热身下,给出SpringMVC调用流程图,讲解的是一个http request请求到达SpringMVC框架后 ...

  8. test 2017-1-5

    //    dpm(drupal_get_filename('module','devel'));//    sites/all/modules/contrib/dev/devel/devel.mod ...

  9. vCSA加域&vcenter关联域&设置管理员权限

    vCSA 与 Windows vCenter对比 1.部署起来更简单快捷. 2.vCSA基于Linux授权费用节省. 3.功能在6.0之后达到与Windows vCenter一样的功能,之后可能会反超 ...

  10. javascript event(事件对象)详解

    javascript event(事件对象)详解   1. 事件对象     1. 事件对象 Event 对象代表事件的状态,比如事件在其中发生的元素.键盘按键的状态.鼠标的位置.鼠标按钮的状态. 什 ...