Python解決codeforces

來源:互聯網
上載者:User

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

output
input
output

  

直接暴力枚舉

# 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).

Output

Sample 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 output

Input

Output

Sample test(s)input

output
input
output
Note


給定一個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"


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.