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; ...
随机推荐
- cpu主频信息
yangkunvanpersie ( yangkunvanpersie@163.com ) 通过"有道云笔记"邀请您查看以下笔记 修改CPU频率.note 打开笔记 kerne ...
- mac攻略(六) -- mac根目录分析
根目录截图如下 符合unix传统的目录 /bin 传统unix命令的存放目录,如ls,rm,mv等. /sbin 传统unix管理类命令存放目录,如fdisk,ifconfig等等. /usr ...
- Sublime Text 3使用指南(2)——快捷键
选择类 快捷键 说明 Ctrl+D 选中光标所占的文本,继续操作则会选中下一个相同的文本. Alt+F3 选中文本按下快捷键,即可一次性选择全部的相同文本进行同时编辑.举个栗子:快速选中并更改所有相同 ...
- Iptables工作原理使用详解
Iptables防火墙简介 Iptables名词和术语 Iptables工作流程 基本语法 Filter 参数说明 NAT表: Icmp协议 TCP FLAG 标记 什么是状态检测 iptables的 ...
- DDS转换工具
本工具用于将(长宽均为 2 的指数次幂的)图像文件如 PNG.TGA.BMP.JPG 等转换为 DDS 图像(DXT 压缩类型可选,DXT1~DXT5),也可将 DDS 图像转换回此几种格式图片. 截 ...
- 18-ES6(1)
第18课-ES6(1) 模块化 1.export和import // model.js export default let m = 1; // 出错 export default n = 2; le ...
- Less2css error 终极解决方案(转载)
用到less时遇到的问题 ,然后复制过来的 使用sublime Text3 的时候,安装less2Css后,和很多人一样以为大功告成,开始要运行编译less文件,结果开始发现 于是乎开始搜索问题和解决 ...
- 更改eclipse的Package Explorer的字体
说一个牛B的不像实力派的东西 — 更改eclipse的Package Explorer的字体1. 打开eclipse目录/Applications/Eclipse.app/Contents/Eclip ...
- 使用python操作FTP上传和下载
函数释义 Python中默认安装的ftplib模块定义了FTP类,其中函数有限,可用来实现简单的ftp客户端,用于上传或下载文件,函数列举如下 ftp登陆连接 from ftplib import F ...
- 关于xml配置实现AOP的小知识
除了前面介绍的基于JDK1.5的注解方式来定义切面,切入点和增强处理外,Spring AOP也允许直接使用XML配置文件来管理它们.在JDK1.5之前,只能使用配置文件的方式来管理,在Spring2. ...