問題一覧 > 通常問題

No.685 Logical Operations

レベル : / AI推定難易度 : 1700 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 57
作問者 : Pulmn / テスター : はむこ
お気に入りにしたユーザー ProblemId : 1783 / 自分の提出
問題文最終更新日: 2026-06-26 06:07:55
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もしくは右上の雲マークをクリックしてアカウントを作成してください。