목록문제/백준_파이썬 (155)
sm 기술 블로그
import sys input = sys.stdin.readline N, K = map(int, input().split()) P = 1000000007 def pow(base, expo): if expo == 0: return 1 tmp = pow(base, expo // 2) if expo % 2 == 1: return (tmp * tmp % P) * base % P else: return tmp * tmp % P def factorial(N): f = 1 while (N > 1): f = (f * N) % P N -= 1 return f # A는 분자 B는 분모 # 분자 N! A = factorial(N) # 분모 (K! * (N-K)!) mod p B = factorial(K) * factoria..
import sys input = sys.stdin.readline A, B, C = map(int, input().split()) def power(A, B, C): if B == 0: return 1 tmp = power(A, B//2, C) if B % 2 == 1: return (tmp * tmp * A) % C else: return (tmp * tmp) % C print(power(A, B, C)) 문제요약 A,B,C가 주어지는데 A를 B번 곱한 값을 C로 나누어라 (A,B,C
import sys input = sys.stdin.readline N = int(input()) paper = [list(map(int, input().split())) for _ in range(N)] result = [] def find(x, y, N): color = paper[x][y] for i in range(x, x+N): for j in range(y, y+N): if color != paper[i][j]: for k in range(3): for l in range(3): find(x + k * N // 3, y + l * N // 3, N // 3) return if color == -1: result.append(-1) elif color == 0: result.append(0) e..
import sys input = sys.stdin.readline N = int(input()) paper = [list(map(int, input().rstrip())) for _ in range(N)] result = [] def find(x, y, N): color = paper[x][y] for i in range(x, x+N): for j in range(y, y+N): if color != paper[i][j]: result.append(str("(")) find(x, y, N//2) find(x, y+N//2, N//2) find(x+N//2, y, N//2) find(x+N//2, y+N//2, N//2) result.append(str(")")) return if color == 0: ..