반응형

백준 알고리즘 14

백준 알고리즘 [파이썬]: 5. 1차원 배열

5. 1차원 배열-1 1차원 배열 단계 각 숫자가 몇 번 나왔는지 저장하기 위해 일차원 배열을 만드는 문제 www.acmicpc.net #10818 최소, 최대 N = int(input()) arr = list(map(int, input().split())) print(min(arr), max(arr)) #2562 최댓값 arr=[] for i in range(0): arr.append(int(input())) print(str(max(arr))+'\n'+str(arr.index(max(arr))+1)) index : 위치 값 받기(0부터 시작해서 1을 더함) #2577 숫자의 개수 A = int(input()) B = int(input()) C = int(input()) num_list = list(s..

Data/Python 2021.06.22

백준 알고리즘 [파이썬]: 4. While 문

4. While 문 while문 단계 입력이 끝날 때까지 A+B를 출력하는 문제. EOF에 대해 알아 보세요. www.acmicpc.net #10952번 (A+B -5) a,b = map(int, input().split()) while (a!=0 and b!=0): print(a+b) a, b=map(int,input().split()) 0 0 을 입력하면 print 하지 않고 바로 끝남 #10951번 (A+B -4) while True: try: a,b = map(int,input().split()) print(a+b) except: break 입력하지 않고 끝내면 ValueError: not enough values to unpack (expected 2, got 0) 가 나오므로 try ~exce..

Data/Python 2021.06.21

백준 알고리즘 [파이썬]: 3. for문

3.for 문 for문 단계 1부터 N까지의 합을 구하는 문제. 물론 반복문 없이 풀 수도 있습니다. www.acmicpc.net #2739 구구단 i=int(input()) for j in range(1,10): print(i, '*' ,j, '=', i*j) #10950 A+B - 3 for _ in range(int(input())): print(sum(list(map(int,input().split())))) #8398 합 total=0 for i in range(int(input())+1): total += i print(total) #15552 빠른 A+B import sys T = int(sys.stdin.readline()) for i in range(T): a, b = map(int,sy..

Data/Python 2021.06.20

백준 알고리즘 [파이썬]: 2.if문

2.if문 if문 단계 점이 어느 사분면에 있는지 알아내는 문제 www.acmicpc.net #1330 두 수 비교하기 a,b =map(int, input().split()) if a>b: print('>') elif a=90: print('A') elif score >=80: print('B') elif score >=70: print('C') elif score >=60: print('D') else : print('F') #2753 윤년 leap_year = int(input()) if leap_year %4==0 and (leap_year%100!=0| leap_year %400==0) : print(1) else: print(0) #14681사분면 고르기 x=int(input()) y=int(i..

Data/Python 2021.06.19
반응형