728x90
반응형

문제 주소: codeforces.com/problemset/problem/69/A

단순한 사칙연산 문제이다.

x = y = z = 0
for _ in range(int(input())):
    a, b, c = map(int, input().split())
    x += a; y += b; z += c
print("YES" if x == y == z == 0 else "NO")
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

96A-Football  (0) 2021.02.16
236A-Boy or Girl  (0) 2021.02.16
281A-Word Capitalization  (0) 2021.02.16
339A-Helpful Maths  (0) 2021.02.16
263A-Beautiful Matrix  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/96/A

간단한 문자열 문제이다.

"0000000" 또는 "1111111" 이 문자열안에 들어있으면 YES 아니면 NO를 출력해주면 된다.

s = input()
if '0'*7 in s or '1'*7 in s:
    print("YES")
else:
    print("NO")
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

69A-Young Physicist  (0) 2021.02.16
236A-Boy or Girl  (0) 2021.02.16
281A-Word Capitalization  (0) 2021.02.16
339A-Helpful Maths  (0) 2021.02.16
263A-Beautiful Matrix  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/236/A

문자열의 길이가 아니라 문자열에 몇 종류의 문자가 있는지를 알아야 해서 set을 사용해줬다.

s = set(input())
print("IGNORE HIM!" if len(s)%2 else "CHAT WITH HER!")
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

69A-Young Physicist  (0) 2021.02.16
96A-Football  (0) 2021.02.16
281A-Word Capitalization  (0) 2021.02.16
339A-Helpful Maths  (0) 2021.02.16
263A-Beautiful Matrix  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/281/A

문자열은 불변이기에 리스트로 바꿔서 처리해줬다. 

join함수를 사용하면 리스트의 문자열들을 합칠 수 있다.

li = list(input())
if 'a' <= li[0] <= 'z':
    li[0] = li[0].upper()
print(''.join(li))
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

96A-Football  (0) 2021.02.16
236A-Boy or Girl  (0) 2021.02.16
339A-Helpful Maths  (0) 2021.02.16
263A-Beautiful Matrix  (0) 2021.02.16
112A-Petya and Strings  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/339/A

파이썬의 꼼수(잡기술)를 좀 사용해봤다. 

li = sorted(list(map(int, input().split('+'))))
print(*li, sep='+')

파이썬에서 *은 컨테이너 타입의 데이터를 Unpacking 해준다.

EX) *[1, 2, 3] -> 1, 2, 3

print 함수에서 sep를 사용하면 print문의 출력문들 사이에 해당하는 문자를 넣을 수 있다.

EX) print(1, 2, 3, sep='A') -> 1A2A3

728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

236A-Boy or Girl  (0) 2021.02.16
281A-Word Capitalization  (0) 2021.02.16
263A-Beautiful Matrix  (0) 2021.02.16
112A-Petya and Strings  (0) 2021.02.16
282A-Bit++  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/263/A

1의 위치만 알면 쉽게 풀 수 있는 간단한 2차원 배열 문제이다.

li = [list(map(int, input().split())) for _ in range(5)]
for i in range(5):
    for j in range(5):
        if li[i][j] == 1:
            x, y = i, j
            break
print(abs(x-2) + abs(y-2))
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

281A-Word Capitalization  (0) 2021.02.16
339A-Helpful Maths  (0) 2021.02.16
112A-Petya and Strings  (0) 2021.02.16
282A-Bit++  (0) 2021.02.16
118A-String Task  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/112/A

간단한 문자열 문제이다.

파이썬은 별도의 함수를 사용하지 않아도 문자열 비교가 바로바로 되어서 참 편한 것 같다.

s1 = input().lower()
s2 = input().lower()
if s1 == s2:
    print(0)
elif s1 < s2:
    print(-1)
else:
    print(1)
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

339A-Helpful Maths  (0) 2021.02.16
263A-Beautiful Matrix  (0) 2021.02.16
282A-Bit++  (0) 2021.02.16
118A-String Task  (0) 2021.02.16
50A-Domino piling  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/282/A

간단한 문자열 문제이다. in을 사용해서 풀었다.

x = 0
for _ in range(int(input())):
    s = input()
    if "++" in s:
        x += 1
    elif "--" in s:
        x -= 1
print(x)
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

263A-Beautiful Matrix  (0) 2021.02.16
112A-Petya and Strings  (0) 2021.02.16
118A-String Task  (0) 2021.02.16
50A-Domino piling  (0) 2021.02.16
158A-Next Round  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/118/A

간단한 문자열 관련 문제이다. 둘다 맞는 코드이긴 한데 더 좋은 방법이 있을 거 같다.

s = input().lower()
for c in s:
    if c in "aoyeui":
        continue
    print(f".{c}", end='')
print()
s = input().lower()
res = ''
for c in s:
    if c in "aoyeui":
        continue
    res += f".{c}"
print(res)
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

112A-Petya and Strings  (0) 2021.02.16
282A-Bit++  (0) 2021.02.16
50A-Domino piling  (0) 2021.02.16
158A-Next Round  (0) 2021.02.16
231A-Team  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/50/A

처음엔 아래 코드 같이 생각했다. 

M, N = map(int, input().split())
print(M//2 * N + (N//2 if M%2 else 0))

근데 잘 생각해보니 도미노를 못 채우는 공간은 어떤 경우든 항상 마지막 줄 마지막 한 칸이다.

못 채우는 공간이 존재하더라도 그건 딱 "한 칸"이라는 것이다.

따라서 M*N(넓이)에 2를 나눈 값을 내림해준 결과가 정답이 된다. -> M*N//2

M, N = map(int, input().split())
print(M*N//2)
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

282A-Bit++  (0) 2021.02.16
118A-String Task  (0) 2021.02.16
158A-Next Round  (0) 2021.02.16
231A-Team  (0) 2021.02.16
1A-Theatre Square  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/158/A

처음에 점수가 0 보다 커야 등수가 인정된다는 것을 생각 안 하고 풀어서 삽질을 했다.

이래서 문제를 잘 읽어야 한다... 반성하자

n, k = map(int, input().split())
li = list(map(int, input().split()))
cnt = 0
for a in li:
    if a > 0 and a >= li[k-1]:
        cnt += 1
print(cnt)
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

118A-String Task  (0) 2021.02.16
50A-Domino piling  (0) 2021.02.16
231A-Team  (0) 2021.02.16
1A-Theatre Square  (0) 2021.02.16
71A-Way Too Long Words  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/231/A

n개의 입력 중 1의 개수가 2개 이상인 경우가 몇 개 있는지 출력해주면 된다.

sum을 사용해서 합이 2 이상인지를 확인하는 방식)

cnt = 0
for _ in range(int(input())):
    if sum(map(int, input().split())) > 1:
        cnt += 1
print(cnt)

count를 사용해서 1의 개수가 2개 이상인지 확인하는 방식)

cnt = 0
for _ in range(int(input())):
    if input().split().count('1') > 1:
        cnt += 1
print(cnt)
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

50A-Domino piling  (0) 2021.02.16
158A-Next Round  (0) 2021.02.16
1A-Theatre Square  (0) 2021.02.16
71A-Way Too Long Words  (0) 2021.02.16
4A-Watermelon  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/1/A

처음엔 아래 같이 풀었는데 잘 생각해보니 그냥 나눈 결과를 올림을 해주면 되는 거였다.

n//a + (1 if n%a else 0) = ceil(n/a)

n, m, a = map(int, input().split())
res = (n//a + (1 if n%a else 0)) * (m//a + (1 if m%a else 0))
print(res)

올림을 사용한 코드)

from math import ceil

n, m, a = map(int, input().split())
res = ceil(n/a) * ceil(m/a)
print(res)
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

50A-Domino piling  (0) 2021.02.16
158A-Next Round  (0) 2021.02.16
231A-Team  (0) 2021.02.16
71A-Way Too Long Words  (0) 2021.02.16
4A-Watermelon  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/71/A

간단한 문자열 관련 문제이다. len을 사용해서 풀었다.

for _ in range(int(input())):
    s = input()
    if len(s) > 10:
        print(s[0], len(s)-2, s[-1], sep='')
    else:
        print(s)
for _ in range(int(input())):
    s = input()
    print(s[0]+str(len(s)-2)+s[-1] if len(s) > 10 else s)
728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

50A-Domino piling  (0) 2021.02.16
158A-Next Round  (0) 2021.02.16
231A-Team  (0) 2021.02.16
1A-Theatre Square  (0) 2021.02.16
4A-Watermelon  (0) 2021.02.16
728x90
반응형

문제 주소: codeforces.com/problemset/problem/4/A

2보다 큰 짝수는 모두 두 개의 짝수로 나뉜다는 점만 알면 쉽게 풀 수 있다.

w = int(input())
print("YES" if w > 2 and w%2 == 0 else "NO")

 

728x90
반응형

'Agorithm > Codeforces' 카테고리의 다른 글

50A-Domino piling  (0) 2021.02.16
158A-Next Round  (0) 2021.02.16
231A-Team  (0) 2021.02.16
1A-Theatre Square  (0) 2021.02.16
71A-Way Too Long Words  (0) 2021.02.16

+ Recent posts