【python】coedeforces 785A
来源:互联网 发布:共青团中央 知乎 编辑:程序博客网 时间:2024/06/06 04:19
题目并不难,但第一种写法所占内存过大,所以想了第二种写法
第一种写法 内存13920kb
n = int(raw_input())importance = []for i in range(n): importance.append(raw_input())result = 0for item in importance: if item == "Tetrahedron": result += 4 if item == "Cube": result += 6 if item == "Octahedron": result += 8 if item == "Dodecahedron": result += 12 if item == "Icosahedron" : result += 20print result
第二种写法 3408kb
def get_score(item): if item == "Tetrahedron": return 4 if item == "Cube": return 6 if item == "Octahedron": return 8 if item == "Dodecahedron": return 12 if item == "Icosahedron" : return 20 n = int(raw_input())result = 0for i in range(n): result += get_score(raw_input())print result
阅读全文
0 0
- 【python】coedeforces 785A
- [python]python a[::-1]
- Codeforces Round #387 (Div. 2) D && coedeforces 744 D. Winter Is Coming(贪心)
- Codeforces Round #387 (Div. 2) C && coedeforces 744 C Servers(水题)
- Python in a Nutshell
- Python in a Nutshell
- Python in a Nutshell
- python : Sorting a Dictionary
- python,a new begining
- We have a Python
- Python Q&A
- python: sort a list
- A Byte of Python
- a byte of python
- Python copy a list
- python爬虫基础A
- A bite of Python
- A Python game
- python代码实现SVM
- 文档通信(跨域-不跨域)、时时通信(websocket)、离线存储(applicationCache)、开启多线程(web worker)
- day10笔记之包、内部类、匿名内部类
- 编程会像手机拍照操作一样傻瓜
- django简介及环境搭建
- 【python】coedeforces 785A
- Thinking in Java 读书笔记 第二章 一切都是对象
- Oracle创建WM_CONCAT函数
- PAT乙级1037. 在霍格沃茨找零钱(20)
- 初次用construct 2做游戏的总结
- BZOJ 3224 普通二叉树
- 不是吧 这么难?
- 页面静态化
- HDU 6208 The Dominator of Strings