A. Power Consumption Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
watt per minute. T minutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to P watt per minute. Finally, after T minutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes P watt per minute. If Tom moves the mouse or touches the keyboard when the laptop is in the second or in the third mode, it switches to the first (normal) mode. Tom's work with the laptop can be divided into n time periods l, r], [l, r], ..., [ln, rn]. During each interval Tom continuously moves the mouse and presses buttons on the keyboard. Between the periods Tom stays away from the laptop. Find out the total amount of power consumed by the laptop during the period l, rn].
Input
, P, P, P, T, T (n ≤ 100, 0 ≤ P, P, P ≤ 100, 1 ≤ T, T ≤ 60). The following nlines contain description of Tom's work. Each i-th of these lines contains two space-separated integers li and ri (li < ri ≤ 1440, ri < li + 1 for i < n), which stand for the start and the end of the i-th period of work.
Output
Sample test(s)input
outputinputoutput
直接暴力枚舉
# inputlist = raw_input().split()n,p1,p2,t1,t2,t3 = map(int , list)# solveans = 0pre = -1while n > 0: n -= 1 list = raw_input().split() start,end = map(int , list) ans += (end-start)*p1 if pre != -1: x = start-pre if x > t1: ans += t1*p1 x -= t1 if x > t2: ans += t2*p2 x -= t2 ans += x*p3 else: ans += x*p2 else: ans += x*p1 pre = endprint ans
A. Increasing Sequencetime limit per test1 secondmemory limit per test64 megabytesinputstandard inputoutputstandard output, a, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t.
, b, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to it. What is the least number of moves required to make the given sequence increasing?
Input and d (n ≤ 2000, 1 ≤ d ≤ 10). The second line contains space separated sequence b, b, ..., bn - 1 (bi ≤ 10).
OutputSample test(s)input
output
枚舉每一個數求個數即可
# inputn,d = map(int , raw_input().split())list = map(int , raw_input().split())# getAnsans = 0for i in range(1,len(list)): if list[i] <= list[i-1]: x = (list[i-1]-list[i])/d+1 list[i] += x*d ans += xprint ans
A. Super Agenttime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputInput
Output
Sample test(s)input
outputinputoutputNote
給定一個3*3的矩形,每個元素不是X就是.,問這個矩形是否是對稱的
暴力枚舉每一個點,然後判斷每個點是否和它的對稱點都相等即可
# inputmatrix = []for i in range(3): matrix.append(raw_input())# solvedef isOk(): for i in range(3): for j in range(3): x = 2-i y = 2-j if matrix[i][j] != matrix[x][y]: return False return True# ouputif isOk(): print "YES"else: print "NO"