Created
June 3, 2018 07:32
-
-
Save pn11/8bb04cd674e8adc3f25b7332fb96d23e to your computer and use it in GitHub Desktop.
AtCoder 2018/06/02
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A = int(input()) | |
B = int(input()) | |
for i in reversed(range(A+1)): | |
if i % B == 0: | |
print(i) | |
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
line1 = input().split() | |
line2 = input() | |
n_short = int(line1[0]) | |
n_cheese = int(line1[1]) | |
n_customer = int(line1[2]) | |
for i in range(n_customer): | |
customer = line2[i] | |
if customer == 'S': | |
if n_short > 0: | |
n_short -= 1 | |
elif customer == 'C': | |
if n_cheese > 0: | |
n_cheese -= 1 | |
elif customer == 'E': | |
if n_short >= n_cheese: | |
if n_short > 0: | |
n_short -= 1 | |
else: | |
if n_cheese > 0: | |
n_cheese -= 1 | |
print(n_short) | |
print(n_cheese) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
line1 = input().split() | |
line2 = input().split() | |
N = int(line1[0]) | |
D = int(line1[1]) | |
X = [int(l2) for l2 in line2] | |
counter = 0 | |
for i in range(N-2): | |
for j in range(i+1, N-1): | |
for k in range(j+1, N): | |
dist_ij = X[j] - X[i] | |
dist_jk = X[k] - X[j] | |
dist_ik = X[k] - X[i] | |
if dist_ij <= D and dist_jk <= D and dist_ik > D: | |
counter += 1 | |
print(counter) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
line1 = input().split() | |
line2 = input().split() | |
H = int(line1[0]) | |
W = int(line1[1]) | |
N = int(line2[0]) | |
M = int(line2[1]) | |
hanko = [] | |
for i in range(N): | |
line = input() | |
row = [line[j] for j in range(M)] | |
hanko.append(row) | |
hanko = np.array(hanko) | |
sheet = np.zeros((H, W), np.bool) | |
for i in range(H-N+1): | |
for j in range(W-M+1): | |
hanko_pad = np.pad(hanko, [(i, H-N-i),(j, W-M-j)], 'constant') | |
# print(sheet.shape) | |
# print(hanko_pad.shape) | |
sheet[hanko_pad=='#'] = 1 | |
# print(sheet) | |
#print(hanko) | |
#print(sheet) | |
print(int(np.sum(sheet))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment