Algorithm (2139) 썸네일형 리스트형 (C++) - 백준(BOJ) 18408 : 3 つの整数 (Three Integers) https://www.acmicpc.net/problem/18408 18408번: 3 つの整数 (Three Integers) 3 つの整数 A, B, C が与えられる.A, B, C はそれぞれ 1 または 2 である.1 と 2 のうち,どちらが多くあるか. www.acmicpc.net for문과 max함수를 사용해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 3개의 정수의 빈도수를 세줄 일차원 배열 a, 최다 빈도수를 비교할 변수 cnt를 선언 후 3개의 정수를 입력 후 a에 빈도수를 세주어 저장합니다. 📔 풀이과정 1. for문을 돌며 가장 많이 나온 빈도수를 cnt에 저장합니다. 2. for문을 돌며 cnt와 같은 값이 나온다면 index를 출력하고 break;해줍니다. 📕 Code #include us.. (C++) - 백준(BOJ) 18330 : Petrol https://www.acmicpc.net/problem/18330 18330번: Petrol The input consists of two lines. The first line contains an integer n (0 ⩽ n ⩽ 200), specifying the amount of petrol that will be used in the next month. The second line contains an integer k (0 ⩽ k ⩽ 360), showing the quota left in Mahya’s fuel www.acmicpc.net 간단한 산수문제였습니다. 📕 풀이방법 📔 입력 및 초기화 다음달에 쓸 예정인 리터수 usePlan, 이번달에 쓰고 남은 리터수 leftLiter를 선.. (C++) - 백준(BOJ) 18005 : Even or Odd? https://www.acmicpc.net/problem/18005 18005번: Even or Odd? Output 2 if the sum of any n consecutive integers in the range from 1 to 1018 must be even, 1 if the sum must be odd, or 0 if the sum could be either even or odd. www.acmicpc.net 정수론 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 등차가 1인 연속 정수 구간의 길이 n을 선언 후 입력받습니다. 📔 풀이과정 2가지 경우가 있습니다. 1. n이 홀수인 경우 : 연속 구간이 홀수라면 (짝수가 짝수개, 홀수가 홀수개), (짝수가 홀수개, 홀수가 짝수개) 두 경우이므로.. (C++) - 백준(BOJ) 17903 : Counting Clauses https://www.acmicpc.net/problem/17903 17903번: Counting Clauses The input is a single instance of the 3-SAT problem. The first line is two space-separated integers: m (1 ≤ m ≤ 20), the number of clauses and n (3 ≤ n ≤ 20), the number of variables. Then m clauses follow, one clause per line. Each clause consists www.acmicpc.net if문을 사용해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 절의 개수 n, 한 절의 literal의 개수 m, 절과 l.. (C++) - 백준(BOJ) 17874 : Piece of Cake! https://www.acmicpc.net/problem/17874 17874번: Piece of Cake! The input consists of a single line containing three integers n (2 ≤ n ≤ 10 000), the length of the sides of the square cake in centimeters, h (0 length >> h >> v; width[0] = v, width[1] = length - v; height[0] = h, height[1] = len.. (C++) - 백준(BOJ) 16785 : ソーシャルゲーム (Social Game) https://www.acmicpc.net/problem/16785 16785번: ソーシャルゲーム (Social Game) JOI 君が少なくとも C 枚のコインを得るためにログインしなければならない回数の最小値を出力せよ. www.acmicpc.net loop문을 사용해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 매 로그인 시 받는 동전 수 a, 7일 연속 로그인 시 받는 동전 수 b, 목표 동전 수 c를 선언 후 입력받습니다. 몇 째날인지를 나타낼 변수 day, 동전의 개수 coin을 선언해줍니다. 📔 풀이과정 coin < c인동안 while loop를 돕니다. 매 loop마다 day는 하루 증가합니다. 7일 연속 로그인시 coin 에 b를 더하고 모든 경우에는 a를 더해줍니다. 📔 정답출력 day를 출.. (C++) - 백준(BOJ) 16693 : Pizza Deal https://www.acmicpc.net/problem/16693 16693번: Pizza Deal There’s a pizza store which serves pizza in two sizes: either a pizza slice, with area A1 and price P1, or a circular pizza, with radius R1 and price P2. You want to maximize the amount of pizza you get per dollar. Should you pick the pizza slice or the www.acmicpc.net if문을 사용해보는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 피자 슬라이스 면적 a1, 피자 슬라이스 가격 p1, 피자 1.. (C++) - 백준(BOJ) 16648 : Accumulator Battery https://www.acmicpc.net/problem/16648 16648번: Accumulator Battery The only line of the input contains two integers t and p — time Anna needs to get from her home to the meeting place, in minutes, and the battery level of her phone at the moment of meeting, in percent (1 ≤ t ≤ 360; 1 ≤ p ≤ 99). www.acmicpc.net 방정식을 세우고 공식을 도출해 답을 출력하는 문제였습니다. 📕 풀이방법 📔 입력 및 초기화 미팅 장소에 도착까지 걸리는 t분, t분 지나 도착하니 100%에.. 이전 1 ··· 128 129 130 131 132 133 134 ··· 268 다음