CodeForces #362 div2 B. Barnicle
题目链接: 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的更多相关文章
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- Codeforces #263 div2 解题报告
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现r ...
- codeforces #round363 div2.C-Vacations (DP)
题目链接:http://codeforces.com/contest/699/problem/C dp[i][j]表示第i天做事情j所得到最小的假期,j=0,1,2. #include<bits ...
- codeforces round367 div2.C (DP)
题目链接:http://codeforces.com/contest/706/problem/C #include<bits/stdc++.h> using namespace std; ...
随机推荐
- 完整安装cocoaPods
cocoaPods是一款xcode项目管理第三方库的工具 *ruby源码镜像下载:https://ruby.taobao.org/mirrors/ruby/*升级gem的版本: $sudo gem u ...
- Instantaneous Transference--POJ3592Tarjan缩点+搜索
Instantaneous Transference Time Limit: 5000MS Memory Limit: 65536K Description It was long ago when ...
- 两个NetSuite之间历史交易数据迁移的具体方案
背景与展望: 比如:公司要上市往往会要求提供过去几年的营业数据和报表等信息, 而这些信息来源于正在一直运营使用的ERP和财务系统是最可靠与真实的. NetSuite实现的ERP和财务系统的完美结合,随 ...
- [转]DataURL与File,Blob,canvas对象之间的互相转换的Javascript
来源 http://blog.csdn.net/cuixiping/article/details/45932793 canvas转换为dataURL (从canvas获取dataURL) var d ...
- iOS_XCode7_Launch Image 的初使用
之前一直没有做笔记的习惯,后来发现很多知识不常用,容易忘了,再去网上找的,很浪费时间,现在尝试着自己写写博客,可以是自己笔记,方便以后查询,如果有纰漏,欢迎指正. 1.Xcode7中 ,assets. ...
- [HIHO1393]网络流三·二分图多重匹配
题目链接:http://hihocoder.com/problemset/problem/1393 把项目到汇点的边权值都加起来,跑完最大流后看是否最大流=权值和.如果等于权值和说明所有项目都有足够的 ...
- python 中的 try/except/else/finally语句
1.python中try/except/else/finally正常的语句是这样的: try: normal excute block except A: Except A handle except ...
- OpenCV从入门到放弃系列之——core模块.核心功能(一)
Mat - 基本图像容器 世间的图像是各种各样的,但是到了计算机的世界里所有的图像都简化为了数值矩以及矩阵信息.作为一个计算视觉库,OpenCV的主要目的就是处理和操作这些信息,来获取更高级的信息,也 ...
- 【树莓派】关于tinyproxy问题处理
一.tinyproxy服务启动问题解决 在配置好树莓派的设备上,发现 tinyproxy 启动时候存在问题,如下图: 经过半天的折腾,后来发现原来是由于异常关机导致临时文件生成错误 解决办法:删除/t ...
- Java学习路线图,专为新手定制的Java学习计划建议
怎么学习Java,这是很多新手经常会问我的问题,现在我简单描述下一个Java初学者到就业要学到的一些东西: 首先要明白Java体系设计到得三个方面:J2SE,J2EE,J2ME(KJAVA).J ...