A. Power Consumption Calculationtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output
Watt per minute. TMinutes after Tom moved the mouse or touched the keyboard for the last time, a screensaver starts and power consumption changes to PWatt per minute. Finally, after TMinutes from the start of the screensaver, laptop switches to the "sleep" mode and consumes PWatt 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 nTime periods l, Bytes,R], Region [L, Bytes,R], Numbers..., numbers [LN, Bytes,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, Bytes,RN].
Input
, P, P, P, T, T(NLimit ≤ limit 100, limit 0 limit ≤ limitP, Bytes,P, Bytes,PLimit ≤ limit 100, limit 1 limit ≤ limitT, Bytes,TLimit ≤ limit 60). The following nLines contain description of Tom's work. Each I-Th of these lines contains two space-separated integers lIAnd rI(LILatency <latencyRILimit ≤ limit 1440, rILatency <latencyLIGeneration + Generation 1 for ILatency <latencyN), Which stand for the start and the end of the I-Th period of work.
Output
Sample test (s) input
OutputInputOutput
Direct brute force Enumeration
# 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, Bytes,A, Please..., please ,...,ATSignature-encoding 1 is called increasing ifIExecutor-cores 1 cores <CoresAIFor each I: Defaults 0 then <thenILatency <latencyT.
, Bytes,B, Please..., please ,...,BNRandom-between 1 and a positive integer d. In each move you may choose one element of the given sequence and add dTo it. What is the least number of moves required to make the given sequence increasing?
InputAnd d(NLimit ≤ limit 2000, limit 1 limit ≤ limitDLimit ≤ limit 10). The second line contains space separated sequence B, Bytes,B, Please..., please ,...,BNAccept-limit 1 (BILimit ≤ limit 10 ).
OutputSample test (s) input
Output
Calculate the number of each number.
# 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
Given a 3*3 rectangle, each element is not X. Ask whether the rectangle is symmetric.
Enumerate each vertex by brute force, and then determine whether each vertex is equal to its symmetric point.
# 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"