목차
문제 정보
https://codeforces.com/problemset/problem/1475/A
Problem - 1475A - Codeforces
codeforces.com
난이도 : A
유형 : Math
문제 풀이
주어진 숫자가 짝수일 경우 2로 계속 나누어서 홀수로 만든 다음 결괏값이 3 이상인 홀수이면 정답이다.
코드
import java.io.BufferedReader
import java.io.InputStreamReader
fun solution() = with(BufferedReader(InputStreamReader(System.`in`))) {
var sb = StringBuilder()
var t = readLine().toInt()
while (t-- > 0) {
var input = readLine().toLong()
if(input %2 == 1L) {
sb.append("YES")
continue
}
while (input % 2 != 1L) {
input /= 2
}
if (input >= 3) {
sb.append("YES")
} else {
sb.append("NO")
}
sb.append('\n')
}
print(sb)
}
fun main() {
solution()
}
'Algorithm, Problem Solving > codeforces' 카테고리의 다른 글
[codeforces][Kotlin] 500A - New Year Transportation (0) | 2023.04.02 |
---|---|
[codeforces][Kotlin] 1367B - Even Array (0) | 2023.03.30 |
[codeforces][Kotlin] 703A - Mishka and Game (0) | 2023.03.28 |
[codeforces][Kotlin] 313A - Ilya and Bank Account (0) | 2023.03.27 |
[codeforces][Kotlin] 466A - Cheap Travel (0) | 2023.03.25 |
댓글