브루트포스 알고리즘
1. 걸리는 시간에 따라 sort
2. 각 사람의 걸리는 시간을 모두 합
n = int(input())
P = list(map(int,input().split()))
P.sort()
sum = 0
for i in range(n):
for j in range(i+1):
sum += P[j]
print(sum)
https://www.acmicpc.net/problem/11399
최소공배수 찾기
lcm(a,b) = a*b/gcd(a,b) 이용
#유클리드 호제법
num = int(input())
for i in range(num):
a,b = map(int,input().split())
A,B = a,b
while a!=0:
b = b%a
a,b = b,a
# print(a,b)
gcd = b
lcm = A * B //b
print(lcm)
https://www.acmicpc.net/problem/1934
브루트포스 알고리즘
값을 1씩 증가시키면서 다음 666이 나올 때까지 반복
n= int(input())
k = 666
for _ in range(1,n):
k += 1
while True:
if '666' not in str(k):
k += 1
else:
break
print(k)
https://www.acmicpc.net/problem/1436
https://www.acmicpc.net/problem/1008
1의 자리만 생각하면됨. -> 10가지 경우만 생각하면된다.
0: 10
1: 1
2: 2 4 8 6
3: 3 9 7 1
4: 4 6
5: 5
6: 6
7: 7 9 3 1
8: 8 4 2 6
9: 9 1
(0),(1, 5, 6),(4,9),(2,3,7,8) 끼리 묶어서 풀기