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 #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; ...
- codeforces 235 div2 C Team
题目:http://codeforces.com/contest/401/problem/C 题意:n个0,m个1,求没有00或111的情况. 这么简单的题..... 做题的时候脑残了...,今天,贴 ...
- Codeforces #245(div2)
A:A. Points and Segments (easy) 题目看了n久,開始认为尼玛这是div2的题目么,题目还标明了easy.. 意思是给你一n个点,m个区间,在n个点上放蓝球或者红球,然后让 ...
- codeforces #262 DIV2 C称号Present(二分法+贪婪)
职务地址:http://codeforces.com/contest/460/problem/C 这个题是用二分枚举最小值.然后推断是否能在规定的次数内使得全部的数都达到这个值.推断的时候要用贪心的方 ...
- codeforces 369 div2 C dp
http://codeforces.com/contest/711 C. Coloring Trees time limit per test 2 seconds memory limit per t ...
- Codeforces#371 Div2
这是一场非常需要总结的比赛,交了3题,最后终测的时候3题全部没过,一下掉到了绿名,2333 Problem A 题意:给定区间[l1,r1],[l2,r2],然后给定一个整数k,求区间当中相交的元素, ...
- codeforces #321 DIV2
A题: 链接:http://codeforces.com/contest/580/problem/A dp,最长连续不上升子序列 #include<iostream> #include&l ...
随机推荐
- 使用Unified Communications Managed API获取Lync在线会议的链接地址
最近在项目上遇到一个问题,需要能够在程序中获取Lync会议的链接地址.Lync是微软出品的一套即时通信(IM)客户端软件,配合Microsoft Lync Server使用,其前身是Microsoft ...
- 浅谈JSON
JSON的全称是”JavaScript Object Notation”,意思是JavaScript对象表示法,它是一种基于文本,独立于语言的轻量级数据交换格式.XML也是一种数据交换格式,为什么没有 ...
- 在datagrid中实现单击行选择整行
首先添加列:<asp:ButtonColumn Text="选择" CommandName="Select" Visible="False&qu ...
- 如何将ASP.NET MVC所有参数均自动设置为默认
今天看到CSDN上有个问题觉得有点意思:"可不可以ASP.NET MVC所有参数均自动设置为默认" public class HomeController : Controller ...
- (转)深入理解javascript连续赋值表达式
引入 今天逛园子的时候看到一道javascript面试题,是关于连续赋值的,正好最近读jQuery源码经常看到这种连续赋值的表达式,所以很感兴趣. 废话不多说,来看题: var a = {n: 1} ...
- 学习ASP.NET MVC(一)——我的第一个ASP.NET MVC应用程序
学习ASP.NET MVC系列: 学习ASP.NET MVC(一)——我的第一个ASP.NET MVC应用程序 学习ASP.NET MVC(二)——我的第一个ASP.NET MVC 控制器 学习ASP ...
- css实现背景颜色线性渐变
http://www.qttc.net/201304316.html http://www.ruanyifeng.com/blog/2008/05/css_background_image_posit ...
- Android开发学习笔记:浅谈WebView(转)
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://liangruijun.blog.51cto.com/3061169/647456 ...
- 解读Gartner《2015年度新兴技术成熟度曲线报告》
详细见:http://www.360doc.com/content/16/0209/16/26186435_533443133.shtml 今年的报告评估了112个领域超过2000项新型技术的市场类型 ...
- 每天一个linux命令(21):tar命令
通过SSH访问服务器,难免会要用到压缩,解压缩,打包,解包等,这时候tar命令就是是必不可少的一个功能强大的工具.linux中最流行的tar是麻雀虽小,五脏俱全,功能强大. tar 命令可以为linu ...