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; ...
随机推荐
- div+css 设计下拉
css样式 <style type="text/css"> <!-- /* www.divcss5.com CSS下拉菜单实例 */ * { margin:; p ...
- dom4j如何解析XML文件
最近在 一些对xml文件的操作,下面简单写一个dom4j解析xml文件并将其封装到一个javabean中的例子,只是具有针对性的,不是通用的,仅供参考哦~~ 首先说:dom4j是一个java的XML ...
- Oracle(创建视图)
概念: 视图:所谓视图就是提取一张或者多张表的数据生成一个映射,管理视图可以同样达到操作原表的效果,方便数据的管理以及安全操作. 视图其实就是一条查询sql语句,用于显示一个或多个表或其他视图中的相关 ...
- 承接unity外包:2016年VR产业八大发展趋势
在上周进行的2016年全球游戏开发者大会(GDC)期间,虚拟现实技术是一个重要议题.英文科技媒体VentureBeat近日刊出了一篇文章,对2016年VR产业的发展趋势进行了预测.游戏陀螺对文章分享的 ...
- Windows_RTM_RC
1.https://zhidao.baidu.com/question/172764638.html RTM(Release to Manufacturing)版 软件在正式在零售商店上架前,需要一段 ...
- bootstrap笔记
一.栅格系统:<div class="container">内容</div>固定宽度,1200px-margin==1170px<div class= ...
- 数据库查询优化-SQL优化
1.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索引而进行全表扫描,如:select id from t where num is null可以在num上设置默 ...
- python3 装饰器
#Author by Andy#_*_ coding:utf-8 _*_#装饰器的原则及构成:# 原则:# 1.不能修改被装饰函数的源代码.# 2.不能修改被装饰函数的调用方式.# 3.不能改变被装饰 ...
- Android 自定义View
Android 自定义View流程中的几个方法解析: onFinishInflate():从布局文件.xml加载完组件后回调 onMeasure() :调用该方法负责测量组件大小 onSizeChan ...
- python——有一种线程池叫做自己写的线程池
这周的作业是写一个线程池,python的线程一直被称为鸡肋,所以它也没有亲生的线程池,但是竟然被我发现了野生的线程池,简直不能更幸运~~~于是,我开始啃源码,实在是虐心,在啃源码的过程中,我简略的了解 ...