YY,MM,DD,dd = map(int,input().split()) if dd > 0: for i in range(1,dd+1): DD += 1 if DD > 13: MM += 1 DD = 1 if MM > 23: YY += 1 MM = 1 else: for i in range(1,abs(dd)+1): DD -= 1 if DD <= 0: MM -= 1 DD = 13 if MM <= 0: YY -= 1 MM = 23 print(YY,MM,DD)
试题D:三位分节法
1 2 3 4 5 6 7 8 9 10 11 12
str = input() str = str[::-1] # 字符串翻转 ans = "" cnt = 0 for i in range(len(str)): if cnt == 3: ans = ans + "," cnt = 0 cnt += 1 ans = ans + str[i] ans = ans[::-1] print(ans)
试题E:水坑题
1 2 3
a,b = map(int, input().split()) ans = (a*b) % (pow(10,9)+7) print(ans)
试题F:站队
Python部分数据超时
1 2 3 4 5 6 7 8 9 10 11 12 13
n = int(input()) data = [] for i in range(1, n+1): tmp = list(map(int, input().split())) tmp.append(i) data.append(tmp)
data = sorted(data,key=lambda x:x[1]) data = sorted(data,key=lambda x:x[0])
for i in range(n-1): print(data[i][2], end=" ") print(data[n-1][2])
试题G:冷门进制
试题H:拯救阿拉德大陆
1 2 3 4 5 6 7 8 9 10 11 12
n = int(input()) nums = list(map(int, input().split())) ans = 0
for i in range(1,n+1): for num in nums: if i % num == 0: ans += 1 break else: continue print(ans)
defdfs(x, y): if x < 0or y < 0or x > n - 1or y > m - 1or vis[x][y] == 1or arr[x][y] == '0': return vis[x][y] = 1 global ans ans += 1 dfs(x - 1, y) dfs(x + 1, y) dfs(x, y + 1) dfs(x, y - 1)
if __name__ == '__main__': n, m ,x, y= map(int, input().split())
arr = [] for i in range(n): str = input() arr.append(list(str))
vis = [[0for _ in range(m)] for _ in range(n)] # 判断是否走过,0为未走过,1为走过 ans = 0