学python嘻嘻,每题第一个是自己的代码,后面的是看见有些好的代码就顺手保存一波了~侵删
import math def isok(X: int,L: int, Z:int)->bool: if(Z>=180) : Z = 360 - Z; if(5*L*1.0 >= math.pi*Z*X/90) : return True return False T = int(input()) while(T): T=T-1 X, L, Z = map(int, input().split()) if(isok(X,L,Z)) : print("YES") else : print("NO")
N = int(input()) flag = False for i in range(2,N+1): for j in range(2,i): for k in range(j,i): for m in range(k,i): if(i*i*i==j*j*j+k*k*k+m*m*m): flag = True print("(%d,%d,%d,%d)"%(i,j,k,m)) if(not flag): print("OMG")
n = int(input()) big, small,tmp =" " c, k, g, t, v, V =0, 0, 0, 0, 25001, -1 for i in range(n): c, k, g, tmp= input().split() t = int(c) * int(k) * int(g) if(t > V) : V, big = t, tmp if(t < v) : v, small =t, tmp print("%s %s"%(big,small))
*******************
n = int(input()) V, big = -1, '' v, small = 25001, '' for i in range(n): arr = input().split() t = int(arr[0]) * int(arr[1]) * int(arr[2]) if(t > V) : V, big = t, arr[3] if(t < v) : v, small =t, arr[3] print("%s %s"%(big,small))
********************
def select(L: list())->int: return L[4] n = int(input()) children = list() for i in range(0,n): temp = input().split(' ') volume = int(temp[0]) * int(temp[1]) * int(temp[2]) temp.append(volume) children.append(temp) children.sort(key = select) print(str(children[n-1][3]) + ' ' + str(children[0][3]))
arr = list(map(int,input().split())) le = len(arr) ans = 0 for i in range(le-1): for j in range(i, le-1): if arr[i]==2*arr[j] or arr[i]*2==arr[j]: ans += 1 print(ans)
********************
arr = list(map(int, input().split())) if arr[-1] == 0: arr.pop() ans = 0 for x in arr: ans += arr.count(2 * x) print(ans)