Python
def Square(H, W):
for i in range(0, H):
for j in range(0, W):
print("#", end='')
print('')
while True:
H, W = list(map(int, input().split()))
if H == 0 and W == 0:
break
else:
Square(H, W)
print('')
Python
def Square(H, W):
for i in range(0, H):
for j in range(0, W):
if i==0 or i==H-1 or j==0 or j==W-1:
print("#", end='')
else:
print(".", end='')
print('')
while True:
H, W = list(map(int, input().split()))
if H == 0 and W == 0:
break
else:
Square(H, W)
print('')
Python
def Square(H, W):
for i in range(0, H):
for j in range(0, W):
if (i+j)%2==0:
print("#", end='')
else:
print(".", end='')
print('')
while True:
H, W = list(map(int, input().split()))
if H == 0 and W == 0:
break
else:
Square(H, W)
print('')
Python
n = int(input())
for i in range(1, n+1):
x = i
if x%3==0:
print(f" {i}", end='')
else:
while x>0:
if x%10==3:
print(f" {i}", end='')
break
else:
x = x // 10
print('')
Python
n = int(input())
A = list(map(int, input().split()))
for i in reversed(range(0, n)):
if i==0:
print(f"{A[i]}")
else:
print(f"{A[i]} ", end='')
Python
card = [[False for i in range(13)] for j in range(4)]
pattern = ['S', 'H', 'C', 'D']
n = int(input())
for i in range(0, n):
m, h = list(map(str, input().split()))
card[pattern.index(m)][int(h)-1] = True
for i in range(0, 4):
for j in range(0, 13):
if card[i][j]==False:
print(f"{pattern[i]} {j+1}")
Python
card = [[False for i in range(13)] for j in range(4)]
pattern = ['S', 'H', 'C', 'D']
floor = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(0, n):
b, f, r, v = list(map(int, input().split()))
floor[b-1][f-1][r-1] += v
for b in range(0, 4):
for f in range(0, 3):
for r in range(0, 10):
if r==9:
print(f" {floor[b][f][r]}")
else:
print(f" {floor[b][f][r]}", end='')
if b<3:
print(f"####################")
Python
n, m = list(map(int, input().split()))
A = [[0 for i in range(m)] for j in range(n)]
B = [0 for i in range(m)]
for i in range(0, n):
a = list(map(int, input().split()))
for j in range(m):
A[i][j] = a[j]
for i in range(0, m):
b = int(input())
B[i] = b
for i in range(0, n):
ans = 0
for j in range(0, m):
ans += A[i][j] * B[j]
print(ans)
Recommended Posts