oddd
https://blog.csdn.net/cxh21627/article/details/125206659
一、配出最小绝对值
while True: try: l = list(map(int,input().split())) m = 65535*2 L = [] for i in range(len(l)): for j in range(i+1,len(l)): tmp = abs(l[i]+l[j]) if tmp < m: m = tmp L.clear() o = [l[i],l[j],tmp] L.extend(o) print(" ".join(map(str,L))) except: break
二、输出水仙花数
import time while True: try: n = int(input()) m = int(input()) #输入不合法直接返回-1,退出循环 if n<3 or n>7: print(-1) break #确定N位数的范围 start = "1"+"0"*(n-1) end = "9"*n L = [] for i in range(int(start),int(end)+1): tmp = list(str(i)) sum = 0 for j in tmp: sum += int(j)**n if sum == i: L.append(i) if m>len(L): print(L[-1]*m) else: print(L[m]) except: break
三、走方格的方案数
#递归 def fun(x,y): if x == 0 or y == 0: return 1 else: return fun(x-1,y)+fun(x,y-1) while True: try: a,b = map(int,input().split()) print(fun(a,b)) except: break #动态规划 # while True: # try: # n, m = map(int, input().split(' ')) # 横坐标是 n, 竖坐标是m # dp = [[1 for i in range(n + 1)] for j in range(m + 1)] # for i in range(1, m + 1): # for j in range(1, n + 1): # dp[i][j] = dp[i-1][j] + dp[i][j-1] # print(dp[m][n]) # except: # break
四、充分发挥GPU算力
N = int(input()) M = int(input()) arr = sorted(list(map(int, input().split(' ')))) res = 0 tmp = 0 for each in arr: res += 1 if each + tmp > N: tmp -= N - each else: tmp = 0 res += (tmp + 1) // N print(res)