codeforces
文章平均质量分 51
陈见夏_Junokiki
我有勇气浪费。
展开
-
【python】coedeforces 785A
题目并不难,但第一种写法所占内存过大,所以想了第二种写法第一种写法 内存13920kbn = int(raw_input())importance = []for i in range(n): importance.append(raw_input())result = 0for item in importance: if item == "Tetrahedr原创 2017-10-06 22:59:52 · 257 阅读 · 0 评论 -
codeforces 151A【python】
题目不难直接贴代码n, k, l, c, d, p, nl, np = map(int,raw_input().split())line = []every1 = k*l / nlevery2 = c*devery3 = p/npline.append(every1)line.append(every2)line.append(every3)line = sorted(l原创 2017-11-05 18:54:36 · 281 阅读 · 0 评论 -
codeforces551A 【python】
用dictionaryn = int(raw_input())d = {}old_line = map(int,raw_input().split())decrease_line = sorted(old_line)decrease_line = decrease_line[::-1]new_line = old_linefor i in range(n):原创 2017-10-26 12:36:19 · 152 阅读 · 0 评论 -
codeforces 651A python
若两个操纵杆的·电量都为1的话,那么持续时间为0因此需要特别判断:一个操纵杆电量必须大于1,另一个>=1joystick = map(int,raw_input().split())result = 0while True: if (joystick[0] >= 1 and joystick[1] > 1) or (joystick[0]>1 and joy原创 2017-11-12 11:05:13 · 236 阅读 · 0 评论 -
codeforces 731A【python】
需要考虑顺时针与逆时针转换的数字大小,并要在输入的string前加上"a"line = raw_input()line = "a" + linereal_distance = 0total_distance = 0for i in range(1,len(line)): distance1 = abs(ord(line[i]) - ord(line[i-1]))原创 2017-10-25 22:33:15 · 352 阅读 · 0 评论 -
codeforces 471A
拼动物,大象、小熊还是外星人需要先判断是否有四个一样的脚(相同数字的个数>=4)若有,再判断剩余两个数的大小def get_different(li): d = {} for i in range(6): if li[i] not in d: d[li[i]] = 1 else: d原创 2017-11-10 12:44:49 · 258 阅读 · 0 评论 -
codeforces 742A
求1378的n次方的最后一个数字可以发现规律为:8 4 2 6 但需注意:n == 1时,需特判n = int(raw_input())if n == 0: print 1else: if n%4 == 1: print 8 elif n%4 == 2: print 4 elif n%4 == 3: p原创 2017-10-13 17:14:12 · 222 阅读 · 0 评论 -
codeforces706B 【python】
第一版写法(如下)TLE了,所以得用二分啊def get_result(wine_price,today_money): for i in range(len(wine_price)): if wine_price[i] > today_money: return i return len(wine_price)原创 2017-10-28 16:29:45 · 226 阅读 · 0 评论 -
codeforces 467B
思路: 需要将小伙伴的army数xi 先转换为二进制数convert——binary(list)(小函数) 若转换为二进制后的数字个数(list的长度) 并与fedor的二进制(list)相比较,如果不一样的个数 在主代码里计算返回True的次数(朋友的个数)def convert_binary(num): resu原创 2017-10-06 13:26:36 · 309 阅读 · 0 评论 -
codeforces 716A
在原list中,若下标i的数与下标i-1的差值c,则新list更新为line[I]n,c = map(int,raw_input().split())line = map(int,raw_input().split())current_list = [line[0]]for i in range(1,n): if line[i] - line[i-1] <= c:原创 2017-10-03 22:35:40 · 200 阅读 · 0 评论 -
codeforces701A
题目:n个人玩牌,需要每个人手中的牌数之和相等并为最大值思路:每人手中的最大牌数之和为target-sum(总牌数和/n*2) 小函数内循环找到一个数下标构成target-sum,并添加至pair的配对list里 注意:为了避免重复使用,所以已配对的数不可再用(用False和True作为标记)def get_pair(cards, star原创 2017-10-10 16:42:43 · 198 阅读 · 0 评论 -
codeforces 719A 【python】
因为list里的数字都是连续的,所以题目并不难,但要特殊判断结尾的15和0n = int(raw_input())themoon = map(int,raw_input().split())if len(themoon) == 1: if themoon[0] == 15: print "DOWN" elif themoon[0] == 0:原创 2017-10-18 22:48:38 · 163 阅读 · 0 评论 -
codeforces 456A
需要找到性价比最高的电脑(它的价格比某台电脑低,但质量更好),因此我首先写了双重循环(小函数调用),结果显示Time limit exceeded on test 6def lalala(price,quality,start_index,n): for i in range(start_index,n): if price[start_index] qu原创 2017-10-01 15:54:18 · 289 阅读 · 0 评论 -
codeforces 514A
将原来的数转变为更小的数,转变方法为9-t(若9-t比t小),需注意的是,转换后的首位数字不可为0.x = int(raw_input())line = map(int,str(x))if line[0] < 9 and (9-line[0] <line[0]): line[0] = 9-line[0]for i in range(1,len(line)): if原创 2017-09-30 12:51:56 · 194 阅读 · 0 评论 -
codeforces 570A【python】
思路:先找出每个城市里票数最多的人的下标(小函数),在输入时可得到每一行的最大数下标,并将其放入一个新的list之中(every-line-max)。接着就需要用到dictionary了,判断每个下标出现的次数(key),接着再循环次数(key),找出所对应的value等于max-num的最靠前的key。(记得输出时要+1)http://codeforces.com/contest/570/p原创 2017-10-17 20:00:41 · 356 阅读 · 0 评论 -
codeforces 349A
题目并不难,不过要整理好思路 (依次判断25的个数、50的个数),依然需要一个true 和false的判断变量。n = int(raw_input())money = map(int,raw_input().split())price_25 = 0price_50 = 0price_100 = 0result = Truefor item in money: if i原创 2017-10-17 19:51:48 · 274 阅读 · 0 评论 -
codeforces439A
在演唱会中尽量穿插更多的笑话,演唱会的总时长为d,每两首歌的休息10分钟可以讲2个故事,再减去总歌长,除以5,则为除休息时间之外的笑话次数。原创 2017-09-29 17:17:45 · 200 阅读 · 0 评论 -
codeforces749A(python)
n = int(raw_input())result =[] times = n/2if n%2 == 0: for i in range(times): result.append(2) else: for i in range(times-1): result.append(2) result.append(3) p原创 2017-10-06 23:03:20 · 222 阅读 · 0 评论 -
codeforces 560A【python】
只要判断list里面有没有1即可n = int(raw_input())line = map(int,raw_input().split())if 1 in line: print -1else: print 1原创 2017-11-05 18:55:52 · 212 阅读 · 0 评论