본문 바로가기
728x90

java138

[백준] 23335번 : Aliquot Sum(JAVA) https://www.acmicpc.net/problem/23335 23335번: Aliquot Sum A divisor of a positive integer n is an integer d where m = n d is an integer. In this problem, we define the aliquot sum s(n) of a positive integer n as the sum of all divisors of n other than n itself. For examples, s(12) = 1 + 2 + 3 + 4 + 6 = 16, s(21) www.acmicpc.net 풀이 s(n)은 n을 제외한 n의 약수들의 합입니다. 약수들의 합이 더 크면 "abundant", 같으면 "perfect".. 2021. 10. 31.
[백준] 23334번 : Olympic Ranking(JAVA) https://www.acmicpc.net/problem/23334 23334번: Olympic Ranking The first line of the input contains one positive integer n. Then n lines follow. Each of the following lines contains three non-negative integers g, s, b, and the name of a country or NOC. They are separated by blanks. www.acmicpc.net 풀이 금메달, 은메달, 동메달 나눠서 값을 비교한 후 answer를 바꿔주다가 마지막에 제출할 경우 800~900사이로 java11만 될겁니다(시간초과가 나올 수도 있음) 이러한 .. 2021. 10. 30.
[백준] 23336번 : A Sorting Problem(JAVA) https://www.acmicpc.net/problem/23336 23336번: A Sorting Problem You are given an array [p[1], p[2], ..., p[n]] where all the numbers in the array are distinct. In addition, the numbers are positive integers between 1 and n. You can only perform the following operations on the array: Pick two indices x and y such that | www.acmicpc.net 풀이 기본적인 2중 for문 버블정렬을 할 시 시간초과가 나온다. 분할정복으로 부분을 나눠서 체크해주면 된다... 2021. 10. 30.
[백준] 23343번 : JavaScript(JAVA) https://www.acmicpc.net/problem/23343 23343번: JavaScript Print the result of the minus operation (x - y) on one Line. If the result is an integer, please print it without the decimal point. If the result is not a number, please print NaN. www.acmicpc.net 풀이 저는 try catch구문을 이용하여 풀었습니다. 물론 Matches랑 정규식을 이용해서 푸는 풀이랑 char형태로 isdigt를 이용한 풀이가 존재할 수도 있지만, 이게 편해서 이렇게 했습니다. 소스코드 import java.io.BufferedRe.. 2021. 10. 30.
728x90