ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [🐉 백준 7단계] 문자열
    Algorithm/케로베로스 2020. 12. 12. 11:34
    반응형

    백준 7단계

    문자열


     

    11654.

    print(ord(input()))

     

    11720.

    n = int(input())
    a = str(input())
    s = 0
    for i in a:
      i = int(i)
      s += i
    print(s)

    10809.

    import string 
    alpha = list(string.ascii_lowercase)
    answer = []
    
    word = input()
    for a in alpha:
      if a in word:
        answer.append(str(word.index(a)))
      else:
        answer.append('-1')
    
    print(' '.join(answer))

     

    2675.

    t = int(input())
    
    for _ in range(t):
      a, b = input().split()
      answer = ''
      for i in b:
        answer += i*int(a) 
      print(answer)

     

    1157.

    n = input()
    d = {}
    for i in n:
      i = i.upper()
      if i not in d:
        d[i] = 1
      else:
        d[i] += 1
    
    m = max(d.values())
    count = 0
    answer = ''
    for k, c in d.items():
      if m == c:
        count += 1
        answer += k
    
    if count == 1:
      print(answer)
    else:
      print('?')

     

    1152.

    print(len(list(input().split())))

     

    2908.

    a, b = input().split()
    
    new_a = ''
    new_b = ''
    
    for i in range(len(a)-1, -1, -1):
      new_a += a[i]
      new_b += b[i]
    
    if new_a > new_b:
      print(int(new_a))
    else:
      print(int(new_b))

    * 더 간단하게 하는 방법

    a = int(a[::-1]) 
    b = int(b[::-1])

     

    5622.

    time = [i+2 for i in range(0,10)]
    
    n = input()
    count = 0
    for i in n:
      if i in ('A','B','C'):
        count += time[1]
      elif i in ('D', 'E', 'F'):
        count += time[2]
      elif i in ('G', 'H', 'I'):
        count += time[3]
      elif i in ('J', 'K', 'L'):
        count += time[4]
      elif i in ('M', 'N', 'O'):
        count += time[5]
      elif i in ('P', 'Q', 'R', 'S'):
        count += time[6]
      elif i in ('T', 'U', 'V'):
        count += time[7]
      elif i in ('W', 'X', 'Y', 'Z'):
        count += time[8]
      else:
        count += 2
    print(count)

     

    2941.

    c = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z=']
    
    n = input()
    count = 0
    answer = 0
    
    for i in c:
      if i in n:
        answer += n.count(i)
        n = n.replace(i, ' ')
    
    n = n.replace(' ', '')
    answer += len(n)
    print(answer)
    

     

    1316.

    t = int(input())
    count = t
    
    for _ in range(t):
      n = input()
      s = set(n[0])
    
      for i in range(1, len(n)):
        if n[i] != n[i-1] and n[i] in s:
          count -= 1
          break 
        else:
          s.add(n[i])
    
    print(count)
    반응형

    댓글

Designed by Tistory.