Taum and B'day
//自己
def main():
t = int(raw_input())
for _ in range(t):
units = 0
b, w = map(int, raw_input().strip().split(' '))
x, y, z = map(int, raw_input().strip().split(' ')) if min(x, y) + z > max(x, y):
if x > y:
units = y * w + (y + z) * b
else:
units = x * b + (x + z) * w
else:
units = b * x + w * y
print units
main()
学习
系统化的分析思路
xrange()和range()区别
range()建立和返回一个list
xrange()是返回一个生成器
所以对于数据量比较大的,用xrange()更好
//另一个(思维更抽象一级,对问题的分析更深刻,所以答案也简单)
T = int(raw_input()) for i in xrange(T):
B, W = map(int, raw_input().split())
X, Y, Z = map(int, raw_input().split()) X = Y + Z if Y + Z < X else X
Y = X + Z if X + Z < Y else Y print B * X + W * Y
Taum and B'day的更多相关文章
- Go map实现原理
map结构 整体为一个数组,数组每个元素可以理解成一个槽,槽是一个链表结构,槽的每个节点可存8个元素,搞清楚了map的结构,想想对应的增删改查操作也不是那么难
随机推荐
- cs代码实现控件移动TranslateTransform
xaml: <Rectangle> <Rectangle.RenderTransform> <TranslateTransform x:Name="myTran ...
- Codeforces 478D Red-Green Towers
http://codeforces.com/problemset/problem/478/D 思路:dp:f[i][j]代表当前第i层,用了j个绿色方块的方案数,用滚动数组,还有,数组清零的时候一定要 ...
- BZOJ2021: [Usaco2010 Jan]Cheese Towers
2021: [Usaco2010 Jan]Cheese Towers Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 184 Solved: 107[Su ...
- linux 下的对拍
搞了一上午终于弄好了一个对拍,估计以后调试会方便很多. #!/bin/bash while true; do ./makedate>tmp.in ./XXXXX<tmp.in>tmp ...
- hdu3308--LCIS 最大连续递增序列长度
这个是动态的,所以要用线段树维护.代码里有注释因为ls敲成lsum,rs敲成rsum查错查了好久.. #include <set> #include <map> #includ ...
- 在 Java 应用程序中使用 Elasticsearch
如果您使用过 Apache Lucene 或 Apache Solr,就会知道它们的使用体验非常有趣.尤其在您需要扩展基于 Lucene 或 Solr 的解决方案时,您就会了解 Elasticsear ...
- Window的匿名Closing 事件
group.Closing += (sender, e) => { try { Code here } } catch (Exception ex) { Exception here } } ...
- ASP.NET简单文件上传
一>使用FileUpload控件,将其拖入页面: <%@ Page Title="hehe" Language="C#" MasterPageFil ...
- NetAnalyzer笔记 之 九 使用C#对HTTP数据还原
[创建时间:2016-05-12 00:19:00] NetAnalyzer下载地址 在NetAnalyzer2016中加入了一个HTTP分析功能,很过用户对此都很感兴趣,那么今天写一下具体的实现方式 ...
- [Angular 2] Using the @Inject decorator
TypeScript is used heavily as we build up our application, but TypeScript isn’t required. If you wan ...