Holes in the text Add problem to Todo list Problem code: HOLES
import sys def count_holes(letter):
hole_2 = ['A', 'D', 'O', 'P', 'Q', 'R']
if letter == 'B':
return 2
elif letter in hole_2:
return 1
else:
return 0 def main():
n = int(sys.stdin.readline())
for t in sys.stdin:
num = 0
for l in t[:-1]:
num += count_holes(l)
print num main()
学习
raw_input( )和sys.stdin.readline( ) 区别
raw_input()不包含最后\n的换行符号,而后者有
sys.stdin.readline( ).strip(),没有参数,默认去除首尾空格、换行符号
.spilt()再加一个,依照空格,对输入的数据进行分割
IDE
debug的理解
console输入不能立即回显
因为pycharm启用了缓冲,为了高效
psyco.full()
有时确实会导致RE
良好的代码缩进和空格
预定义方式更快
if a in b[]
for循环
没问题,可以挨个循环String, 如果不想要\n(本题随不影响结果,但是多一次函数调用),用[:-1],这种:操作是py一个很大的好处
这次构思和调试都是自己独立完成
加油!
错误
elif ('A' or 'D' or 'O' or 'P' or 'Q' or 'R') == letter: 逻辑判断有错,不能判断A以后的,不能使用
Holes in the text Add problem to Todo list Problem code: HOLES的更多相关文章
- The Lead Game Add problem to Todo list Problem code: TLG
'''def count_lead(first, second): if first > second: return 1, first - second elif first == secon ...
- Turbo Sort Add problem to Todo list Problem code: TSORT
def heap_sort(ary): n = len(ary) first = int(n / 2 - 1) for start in range(first, -1, -1): # 3~0 rev ...
- Problem : 1002 ( A + B Problem II )
经验总结:一定要注意输出的格式,字符的空格,空行,一定要观察清楚.如本题的最后一个输出结果后面没有空行.最后代码实现的时候需要判断一下,代码如下 !=n) cout<<endl; Prob ...
- 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem B. Travelling Camera Problem set贪心
Problem B. Travelling Camera Problem 题目连接: http://www.codeforces.com/gym/100253 Description Programm ...
- Problem B The Blocks Problem(vector的使用)
题目链接:Problem B 题意:有n块木块,编号为0~n-1,要求模拟以下4种操作(下面的a和b都是木块编号) 1. move a onto b: 把a和b上方的木块全部归位,然后把a摞在b上面. ...
- 几何入门合集 gym101968 problem F. Mirror + gym102082 Problem F Fair Chocolate-Cutting + gym101915 problem B. Ali and Wi-Fi
abstract: V const & a 加速 F. Mirror 题意 链接 问题: 有n个人在y=0的平面上(及xoz平面).z=0平面上有一面镜子(边平行于坐标轴).z=a平面上有q个 ...
- A+B Problem Plus and A-B Problem Plus and A*B Problem Plus
//we have defined the necessary header files here for this problem. //If additional header files are ...
- Problem J. Joseph’s Problem 约瑟夫问题--余数之和
链接:https://vjudge.net/problem/UVA-1363 题意:给出n k,当 i 属于 1~n 时 ,求解 n% i 的和 n 和 k 的范围都是 1 到 10^9; 商相同 ...
- POJ - Problem 2282 - The Counting Problem
整体思路:对于每一位,先将当前未达到$limit$部分的段 [如 $0$ ~ $10000$] 直接处理好,到下一位时再处理达到$limit$的部分. · $1 × 10 ^ n$以内每个数(包括$0 ...
随机推荐
- SVM详解
SVM入门(一)至(三)Refresh 按:之前的文章重新汇编一下,修改了一些错误和不当的说法,一起复习,然后继续SVM之旅. (一)SVM的简介 支持向量机(Support Vector Machi ...
- (摘)SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
Linux下安装好Oracle 10g后运行sqlplus出现故障如下:[oracle@localhost oracle]$ ./sqlplusError 6 initializing SQL*Plu ...
- JAVA中,字符串STRING与STRINGBUILDER的效率差异
如果可变字符串操作较多的话,用STRINGBUILDER显然优势得多. public class HelloJava { public static void main(String[] args) ...
- 认识Android
安卓的特点开放性平等性无界性方便性硬件的丰富性 Android操作系统之中,一共将体系结构划分为四层:应用层(Application).应用框架层(Application Framework).系统运 ...
- Altium Designer 等长线&&蛇形线
Altium Designer 里面怎么画等长线 (1)一般是将走线布完后,新建一个class. Design -> Classes 如上图添加完后可以点击close. (2)快捷键 T + R ...
- Altium Designer如何批量修改名称,数值,封装
方法一: altium里的封装管理库 1,Tools -> Footprint Manager -> ...2,在Component List里选择要改的器件3,在View and Edi ...
- 借鉴DP思想: HouseRobberIII
The thief has found himself a new place for his thievery again. There is only one entrance to this a ...
- 【细说Java】Java变量初始化顺序
Java的变量初始化顺序,对这里一直似懂非懂,面试的时候也经常被问到,但答的一直不好,现在整理记录一下,以后忘记了可以来看看. 程序分为两个部分,第一个部分不考虑继承,第二个部分考虑继承: (1)不考 ...
- [Operationg System Labs] 我对 Linux0.00 中 boot.s的理解和注释
(如有错误请立即指正,么么哒!) ! boot.s!! It then loads the system at 0x10000, using BIOS interrupts. Thereafte ...
- ASP.NET获取IP的6种方法(转载于LanceZhang's Tech Blog)
服务端: //方法一 HttpContext.Current.Request.UserHostAddress; //方法二 HttpContext.Current.Request.ServerVari ...