TIL(today i learned)/알고리즘
-
알면 도움되는 bitmaskTIL(today i learned)/알고리즘 2023. 7. 20. 21:15
https://www.acmicpc.net/problem/17497 17497번: 계산기 첫 번째 줄에 버튼을 누른 횟수 K (0 ≤ K ≤ 99) 를 출력합니다. 누른 횟수를 최소화 하지 않아도 됩니다. 단, 누른 횟수가 99번을 넘으면 안됩니다. 만약 99번 안에 N을 만드는 방법이 존재하지 않는 www.acmicpc.net 2진수 연산 특징 a)2를 곱하면 현재 비트뒤에 단순히 0이추가된다. b)현재비트의 맨뒤가 0이면 짝수,1이면 홀수 이다. c)(X & 1)연산은 홀수이면 1 짝수이면 0