1.
# -*- coding: utf-8 -*-
__author__ = 'xl'
"""
__date__ = TIME: 2018/08/11 下午12:34
describe:
"""
from functools import reduce
"""
6 3
1 3 5 2 5 4
1 1 0 1 0 0
"""
line1 = input().strip()
line2 = input().strip()
line3 = input().strip()
class_time,wake_time = map(lambda x:int(x),line1.split(" "))
interest_score_list =list(map(lambda x:int(x),line2.split(" ")))
sleep_time_list =list(map(lambda x:int(x),line3.split(" ")))
max_score = 0
for x in range(class_time-wake_time+1):
count = 0
origin_conut = 0
for i in range(wake_time):
count += interest_score_list[x+i]
for i in range(wake_time):
origin_conut += interest_score_list[x+i] if sleep_time_list[x+i] == 1 else 0
score = count-origin_conut
if max_score < score:
max_score =score
count = 0
for index,value in enumerate(interest_score_list):
if sleep_time_list[index] == 1:
count += value
print(count+max_score)
2.
import numpy as np
line1 = input().strip().split()
max_deal = line1[1]
high = input().strip().split()
deal = []
i_deal = 0
while i_deal < max_deal:
if np.max(high) != np.min(high):
i_deals = []
mymax = np.max(high)
myargmax = np.argmax(high)
i_deals.append(myargmax+1)
mymin = np.min(high)
myargmin = np.argmin(high)
i_deals.append(myargmin+1)
deal.append(i_deals)
high[myargmax] = mymax-1
high[myargmin] = mymin+1
else:
break
i_deal += 1
print(np.max(high)-np.min(high), i_deal)
for i_deals in deal:
print(i_deals[0], i_deals[1])
# -*- coding:utf-8 -*-
#两个素数的乘积所得的自然数为半素数,给定一个数N,求小于或等于N的半素数的数目。0<N<50000
from math import sqrt,ceil
# N = int(input())
# N = input()
N = 5
def isPrime(n):
x = int(ceil(sqrt(n)))
if n ==2 :
return True
for i in range(2,x+1):
if (n%i==0):
return False
return True
# ll = [n for n in range(2,2500) if isPrime(n)==True]
ll = [x for x in range(2,N//2+1) if isPrime(x)==True]
s = {x*y for x in ll for y in ll}
ss = list(s)
ss.sort()
d ={}
for index,value in enumerate(ss):
d.update({value:index+1})
for i in range(N,2,-1):
# print(i)
try:
if i <4:
print(0)
else:
print(d[i])
break
except KeyError as e:
pass