首页 > 编程语言 > 详细

51nod 初学者题库 1级题 python题解

时间:2019-08-27 13:31:18      阅读:235      评论:0      收藏:0      [点我收藏+]

学python嘻嘻,每题第一个是自己的代码,后面的是看见有些好的代码就顺手保存一波了~侵删

 

1916 购物

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")

 

1956费马大定理扩展

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")

 

1957幼儿园霸王

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]))

 

1959好事成双

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)

  

51nod 初学者题库 1级题 python题解

原文:https://www.cnblogs.com/wangzhebufangqi/p/11417674.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!