No.685 Logical Operations
問題文最終更新日: 2026-06-26 06:07:55
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 190
(順位表)
の他の問題:
Problem Statement
You are given a non-negative integer $N$. Find the number of pairs $(x,y)$ satisfying $0\le x\le y\le N$ and $x$ AND $y\lt x$ XOR $y\lt x$ OR $y$, modulo $10^9+7=1{,}000{,}000{,}007$.
Here, AND, XOR, and OR denote bitwise AND, bitwise exclusive OR, and bitwise OR, respectively.
Input
$N$
$0\le N\le 10^{18}$
Output
Print the number of pairs $(x,y)$ satisfying the conditions, modulo $1{,}000{,}000{,}007$. Print a newline at the end.
Sample
Sample 1
Input
10
Output
16
Examples of pairs $(x,y)$ satisfying the conditions include $(3,5),(7,9)$.
When $(x,y)=(3,5)$, $(x$ AND $y,x$ XOR $y,x$ OR $y)=(1,6,7)$.
When $(x,y)=(7,9)$, $(x$ AND $y,x$ XOR $y,x$ OR $y)=(1,14,15)$.
Sample 2
Input
0
Output
0
Note that $N$ is a non-negative integer.
Sample 3
Input
1000
Output
308344
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Pulmn
はむこ