No.822 Bitwise AND
問題文最終更新日: 2019-04-26 21:14:37
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 212
(順位表)
の他の問題:
Problem Statement
You are given non-negative integers $N,K$. Find the number of pairs $(x,y)$ satisfying the following condition. If there are infinitely many, print "INF".
Condition: $x,y$ are non-negative integers satisfying $0\le x\le y$, and they satisfy $y-x\le K$ and $x$ AND $y=N$ (AND denotes the bitwise logical product).
Input
$N$ $K$
$0\le N\le 10^5$
$0\le K\le 300$
Output
Print the number of pairs $(x,y)$ satisfying the condition. If there are infinitely many, print "INF". Print a newline at the end.
Sample
Sample 1
Input
9 5
Output
4
$(x,y)=(9,9),(9,11),(9,13),(11,13)$ satisfy the condition.
Sample 2
Input
0 0
Output
1
$(x,y)=(0,0)$ satisfies the condition.
Sample 3
Input
0 1
Output
INF
$(x,y)=(0,0),(0,1),(1,2),(3,4),(7,8),(15,16),\dots$ satisfy the condition.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Pulmn
ixmel