PAT basic1026-1030(Python版)
来源:互联网 发布:墙壁网络水晶头接线图 编辑:程序博客网 时间:2024/06/05 21:08
Python版的PAT,Python2环境。
1026:
from sys import exitstr = raw_input()for i in range(len(str)):if str[i] == ' ':flag = ibreakc1 = int(str[:flag])c2 = int(str[flag+1:])CTK = 100sec_sum = (c2 - c1) / CTKif (c2 - c1) % 100 >= 50:sec_sum += 1hh = sec_sum / 3600mm = (sec_sum % 3600) / 60ss = sec_sum % 60print "%02d:%02d:%02d" % (hh, mm, ss)exit(0)
1027:
from sys import exitstr = raw_input()for i in range(len(str)):if str[i] == ' ':flag = ibreakc1 = int(str[:flag])c2 = str[flag+1:]c1 += 1num = 0i = 0while 1:c1 -= 2 * ( 2 * i + 1 )i += 1num += 1if c1 < 2 *(2 * i + 1):breakfor j in range(num):print "%s%s" % (j*' ', ( 2*(num-1-j) + 1 )*c2)for j in range(1,num):print "%s%s" % ( (num-j-1)*' ', (2*j + 1)*c2)print c1exit(0)
1028:
from sys import exitdef isValid( birth ): if birth <= "2014/09/06" and birth >= "1814/09/06": return 0 else: return 1str = raw_input()num = int(str)max = []min = []validNum = 0for i in range(num): tmp = raw_input().split() if isValid( tmp[1] ) == 0: validNum += 1 if len(max) == 0 or max[1] > tmp[1]: max = tmp if len(min) == 0 or min[1] < tmp[1]: min = tmpif len(max) != 0: print validNum, max[0], min[0]else: print '0'exit(0)
1029:
from sys import exitstr1 = raw_input()str2 = raw_input()str3 = ""for ch in str1: if not ch in str2: if not (ch in str3 or ch.upper() in str3): str3 += ch.upper()print str3exit(0)
1030:
from sys import exitstr1 = raw_input()str2 = raw_input()Np = str1.split(' ')N = int(Np[0])p = int(Np[1])strNum = str2.split(' ')num = []for i in strNum: num.append(int(i))num.sort() start = 0end = 0maxLen = 0while True: if start == end: end += 1 continue if end >= N: break if num[end] <= p * num[start]: end += 1 else: if maxLen < (end - start): maxLen = end - start start += 1 if end == N: breakif maxLen < end - start: maxLen = end - startprint maxLenexit(0)
刚学Python,代码写的可能不是很规范,请多多指教。
0 0
- PAT basic1026-1030(Python版)
- PAT(Python)-1030:完美数列(25)
- PAT basic1001-1005(Python版)
- PAT basic1006-1010(Python版)
- PAT basic1011-1015(Python版)
- PAT basic1016-1020(Python版)
- PAT basic1021-1025(Python版)
- PAT basic 1027(Python版)
- PAT中文1001-1005(Python 语言)
- PAT(Python)-1020:月饼(25)
- PAT(Python)-1015:德才论(25)
- PAT 1003 Emergency(25)Python
- 1040. 有几个PAT(25)--Python
- PAT 打印沙漏 (Python)
- PAT Shuffling machine (Python)
- PAT basic 1036 python
- PAT(Python)-1010:一元多项式求导(25)
- PAT(Python)-1007:素数对猜想(20)
- linux 线程学习之条件变量
- jQuery取得select选择的文本与值
- Eclipse+tomcat开发j2ee经典入门例子
- C语言--Cleaning shifts
- 嵌入式软件开发---多家企业面经合集
- PAT basic1026-1030(Python版)
- QT QSqlQuery QSqlQueryModel
- POJ2352(树状数组)
- Android Push实现总结
- android webview开发html5之二
- RabbitMQ学习之spring整合发送同步消息(注解实现)
- java异常处理题目
- 安装火蜘蛛采集器,采集天猫新百伦旗舰店商品数据上传到微信
- 利用MySQL存储过程分割字符串