문제풀이 썸네일형 리스트형 [SWEA]8104 조 만들기 1 k 2 2K-k+1 3 2K+k 4 4K-k+1 5 4k+k . . . 문제에서 등수는 이런 식으로 증가한다 (N개의 행과 K개의 열을 가지고 있고 n은 행 번호, k는 열 번호라고 가정할 때) 잘 살펴보면 1행과 2행을 더하면 2k+1, 3행과 4행을 더하면 6k+1과 같이 규칙을 띈다. 이를 고등학생 때 배운 수열에 대입하면 an = (4n-2)K+1이 나온다 수열의 합을 구하면 Sn = (2Kn+1)n 이 나온다. 하지만 언제나 짝수 개의 행이 나오지는 않으므로 N이 홀수이면 Sn = (2Kn+1)n - ((N+1)K-k+1)이 된다. 이를 코드로 다음과 같이 나타낼 수 있다 #include int main(void) { int test_case; int T; setbuf(stdout, NULL.. [SWEA]8457 알 덴테 스파게티 B와 가장 가까운 모래시계 시간과 그 보다 한 타임 줄인 시간과 한 타임 늘인 시간, 총 세 개의 시간과 허용 범위를 비교하였다 #include int main(void) { int test_case; int T; setbuf(stdout, NULL); scanf("%d", &T); for (test_case = 1; test_case [SWEA]8338 계산기 #include int main(void) { int test_case; int T, N, l, r; setbuf(stdout, NULL); scanf("%d", &T); for (test_case = 1; test_case [SWEA]5431 민석이의 과제 체크하기 #include int main(void) { int test_case; int T, N, K, a; setbuf(stdout, NULL); scanf("%d", &T); for (test_case = 1; test_case [SWEA]3431 준환이의 운동관리 별 다를 것 없이 if절을 이용해 풀었다. 아래 풀이는 논리는 같지만 삼항연산자를 이용해 푼 것 #include int main(void) { int test_case; int T; setbuf(stdout, NULL); scanf("%d", &T); for (test_case = 1; test_case [HackerRank]Between Two Sets Between Two Sets You will be given two arrays of integers and asked to determine all integers that satisfy the following two conditions: 1. The elements of the first array are all factors of the integer being considered 2. The integer being considered is a factor of all elements of the second array These numbers are referred to as being between the two arrays. You must determine how many such nu.. [HackerRank]Kangaroo 문제 You are choreographing a circus show with various animals. For one act, you are given two kangaroos on a number line ready to jump in the positive direction (i.e, toward positive infinity). The first kangaroo starts at location x1 and moves at a rate of v1 meters per jump. The second kangaroo starts at location x2 and moves at a rate of v2 meters per jump. You have to figure out a way to get .. [HackerRank]Breaking the Records 문제 Maria plays college basketball and wants to go pro. Each season she maintains a record of her play. She tabulates the number of times she breaks her season record for most points and least points in a game. Points scored in the first game establish her record for the season, and she begins counting from there. Function Description Complete the breakingRecords function in the editor below. It .. 이전 1 2 3 4 5 다음