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 ...
随机推荐
- mongodb 增加用户以及认证用户
test>use admin switched to db admin admin>db.addUser('yshy','yshy') { "user" : " ...
- 使用AlertDialog创建对话框的大致步骤
1.创建AlertDialog.Builder对象,该对象是AlertDialog的创建器.2.调用AlertDialog.Builder的方法为对话框设置图标.标题.内容等.3.调用AlertDia ...
- rm: cannot remove `/home/cn0000/log/formlog.20140417': Read-only file system
[root@localhost home]# su - cn0000 rm: cannot remove `/home/cn0000/log/monitor_xmllog.20140417': Rea ...
- linux下编译eXosip、osip,以及UAC和UAS的例子
从网站上看到了这样的一篇博文 :Windows下编译eXosip.osip,以及UAC和UAS的例子 (链接:http://www.cnblogs.com/dyllove98/archive/2013 ...
- [LeetCode] Maximum Gap 解题思路
Given an unsorted array, find the maximum difference between the successive elements in its sorted f ...
- Spring MVC中各个filter的用法
转载:http://blog.csdn.net/qyp1314/article/details/42023725 Spring MVC中各个filter的用法 2014-12-19 09:08 105 ...
- Mac OS X下HomeBrew安装卸载
1.卸载 cd `brew --prefix` rm -rf Cellar brew prune rm `git ls-files` rm -r Library/Homebrew Library/Al ...
- MySQL获取系统性能和状态
#!/bin/ksh INTERVAL=5 PREFIX=$INTERVAL-sec-status touch /tmp/running RUNFILE=/tmp/running my -e 'sho ...
- C#使用jmail组件发送邮件
1.安装 命令行环境下,到jmail.dll所在目录,运行regsvr32 jmail.dll 2.代码 #region 发送邮件 /// <summary> /// 发送邮件 ...
- Android RatingBar自定义替换系统图片
1.自定义替换提醒☆图片,准备两个图片添加到系统中去:如下: 在drewable下定义一个图片资源ratingbar_drawable.xml 1 2 3 4 5 6 7 8 9 10 ...