程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

The fourth intelligence cup (group B of the preliminary round) | thinking of Python problem solving

編輯:Python

Catalog

  • A Original grade group
  • B Report score
  • C Competitive score
  • D Small cards and prime numbers 2
  • E Radish database

in general , Easier than practice .....
python The running time ranking is not dominant

A Original grade group


Answer key :

t,h,e = map(int,input().split())
grade = t*0.2 + h*0.3 + e *0.5
print(int(grade))

B Report score


Answer key

n = int(input())
list_ = []
score = []
grade = 0
for i in range(n):
a,p = map(int,input().split())
list_.append([a,p])
# i[0] It's the basic score i[1] It's the number of pages
for i in list_:
if i[1] < 16:
if i[0] - 10 < 0:
grade = 0
else:
grade = i[0] - 10
if i[1] > 20:
grade = i[0] - (i[1]-20)
if grade < 0:
grade = 0
if i[1]>=16 and i[1]<=20:
grade = i[0]
print(grade)

C Competitive score

n = int(input())
a_list = list(map(int,input().split()))
min_a = min(a_list)
max_a = max(a_list)
for a in a_list:
grade = 100 * (a-min_a)/(max_a-min_a)
print(int(grade),end=' ')

D Small cards and prime numbers 2

n = int(input())
num_list = []
for i in range(n):
num_list.append(int(input()))
def isPrime3(n):
if n==2:
return True
if n%2 == 0 or n==1:
return False
# Judge only odd numbers , Halve the scope
for i in range(3, int(n**0.5)+1, 2):
if n%i == 0:
return False
return True
for i in num_list:
count = 0
n = 0
while n<i:
num = i^n
if isPrime3(num):
count+=1
n+=1
print(count)

E Radish database

# n operations k A field
n,k = map(int,input().split())
list_ = []
for i in range(n):
list_.append(list(map(int,input().split())))
# Build table
dict_ = {}
for i in range(1,k+1):
dict_[i] = []
for i in range(len(list_)):
# Query initial value is 0
count = 0
list_2 = list_[i][2:]
# This is an insert operation
if list_[i][0] == 1:
for j in range(len(list_2)):
if j%2 == 0:
dict_[list_2[j]].append(list_2[j+1])
# This is a query operation
if list_[i][0] == 2:
min_y = list_[i][2]
max_y = list_[i][3]
for value in dict_[list_[i][1]]:
if value>=min_y and value<=max_y:
count+=1
print(count)

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved