목록전체보기 (378)
코딩로그

[문제] 세 정수 A, B, C의 평균은 (A+B+C)/3이다. 세 정수의 중앙값은 수의 크기가 증가하는 순서로 정렬했을 때, 가운데 있는 값이다. 두 정수 A와 B가 주어진다. 이때, A, B, C의 평균과 중앙값을 같게 만드는 가장 작은 정수 C를 찾는 프로그램을 작성하시오. [입력] 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, A와 B가 주어진다. (1 ≤ A ≤ B ≤ 109) 입력의 마지막 줄에는 0이 두 개 주어진다. [출력] 각 테스트 케이스에 대한 정답을 한 줄에 하나씩 출력한다. [Source Code] #include #include #include #include #include using namespace std; int main()..

[문제] Byteland Airlines recently extended their aircraft fleet with a new model of a plane. The new acquisition has n1 rows of seats in the business class and n2 rows in the economic class. In the business class each row contains k1 seats, while each row in the economic class has k2 seats. Write a program which: reads information about available seats in the plane, calculates the sum of all seats..

[문제] 두 양의 정수가 주어졌을 때, 두 수 사이에 있는 정수를 모두 출력하는 프로그램을 작성하시오. [입력] 두 정수 A와 B가 주어진다. [출력] 첫째 줄에 두 수 사이에 있는 수의 개수를 출력한다. 둘째 줄에는 두 수 사이에 있는 수를 오름차순으로 출력한다. [Source Code] #include #include #include #include #include using namespace std; int main() { long long a, b; cin >> a >> b; if(a > b) swap(a, b); if (a != b) { cout

[문제] Given two integers, calculate and output their sum. [입력] The input contains several test cases. The first line contains and integer t (t ≤ 100) denoting the number of test cases. Then t tests follow, each of them consisiting of two space separated integers x and y (−10^9 ≤ x, y ≤ 10^9). [출력] For each test case output output the sum of the corresponding integers. [Source Code] #include #incl..

[문제] 2018 SCAL-MOOKJA에 출전하기로 한 무근이와 인서는 대회 준비를 위해 같이 모여 문제를 풀기로 했다. 그런데 어느 날, 일어나서 날짜를 확인해 보니 무근이와 인서의 시계가 서로 다른 날짜를 가리키고 있었다. 두 사람이 정확한 날짜에 모일 수 있도록 문제를 푸는 지금 시각이 UTC+0(세계 표준시)을 기준으로 무슨 날짜인지 출력해 주는 프로그램을 작성하자. 만약 서울에서 확인한 시각이 2018년 9월 29일 오후 2시 정각이라면 UTC+0 기준의 시각은 2018년 9월 29일 오전 5시 정각이다. Fri Sep 29 05:00:00 UTC 2018 [입력] 이 문제는 입력이 없다. [출력] 지금 시각을 UTC+0(세계 표준시)을 기준으로 나타냈을 때의 연도, 월, 일을 한 줄에 하나씩 ..

[문제] In the United States of America, telephone numbers within an area code consist of 7 digits: the prefix number is the first 3 digits and the line number is the last 4 digits. Traditionally, the 555 prefix number has been used to provide directory information and assistance as in the following examples: 555-1212 555-9876 555-5000 555-7777 Telephone company switching hardware would detect the ..

[문제] 2와 e는 발음이 비슷해, 둘을 섞어서 말하면 듣는 사람을 짜증나게 만들 수 있다. 지민이는 이 점을 이용해 은수를 미치게 하고 있다. 은수를 위해 지민이가 말한 문자열 s가 주어질때, 2의 등장 횟수가 더 많은지, e의 등장 횟수가 더 많은지 도와주자. [입력] 첫 줄에 문자열 s의 길이가 주어진다. 둘째 줄에 문자열 s가 주어진다. s의 길이는 1 이상 105 이하이며, s는 2와 e로만 이루어져 있다. [출력] 2의 등장횟수가 더 많다면 2를 출력하고, e의 등장횟수가 더 많다면 e를 출력한다. 등장횟수가 같다면 "yee"를 출력한다. (큰 따옴표 제외) [Source Code] #include #include #include #include #include using namespace s..

[문제] You and your friend have come up with a way to send messages back and forth. Your friend can encode a message to you by writing down a positive integer N and a symbol. You can decode that message by writing out that symbol N times in a row on one line. Given a message that your friend has encoded, decode it. [입력] The first line of input contains L, the number of lines in the message. The ne..