Trouble that the start is delayed by 10 minutes.
A. We Love Golf All the values from a to b are searched, and it is OK if it is divisible by k.
ABC165a.py
a=int(input())
b,c=map(int,input().split())
for i in range(b,c+1):
if i%a==0:
print("OK")
exit()
print("NG")
B. 1% Turn the while statement until the total amount including compound interest exceeds x yen. Don't forget to truncate with floor every time.
ABC165b.py
import math
x=int(input())
y=100
i=0
while True:
y=math.floor(y*1.01)
i+=1
if y>=x:
print(i)
exit()
C. Many Requirements I lost a lot of time when I thought about whether to take from the top of the points obtained or whether to delete duplicates of a and b. Since $ N, M, and Q $ are all small, it is enough to search all the expected sequences. Use Itertools combinations_with_replacement to create all possible sequences and output the maximum score.
ABC165c.py
from itertools import *
n,m,q=map(int,input().split())
aaa=[]
for i in range(m):
aaa.append(i+1)
l=[]
for i in range(q):
a=list(map(int,input().split()))
l.append(a)
a=list(combinations_with_replacement(aaa,n))
ans=0
for i in a:
aa=0
for j in l:
if i[j[1]-1]-i[j[0]-1]==j[2]:
aa+=j[3]
if aa>ans:
ans=aa
print(ans)
D. Floor function
The second term is $ 0 $ when $ x <B $, otherwise it is a positive integer. Therefore, when $ x
Therefore, when $ n> = B $, $ x = b-1 $ should be output, and when $ n <B $, $ x = n $ should be output as $ f (x) $.
ABC165d.py
import math
a,b,n=map(int,input().split())
if b<=n:
print(math.floor(a*(b-1)/b))
else:
print(math.floor(a*(n)/b))
I've run out of time until the D problem today ... I want to use what I've learned, such as DP and search algorithms, in practice as soon as possible.
Recommended Posts