baekjoon 20260115

This commit is contained in:
songyc macbook 2026-01-15 22:50:44 +09:00
parent 8d396cd114
commit 06b9cd2782
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,32 @@
#include <stdio.h>
typedef long long ll;
ll dp[55];
ll count_one(ll N);
int main() {
ll A, B;
scanf("%lld %lld",&A, &B);
for(int i=1; i<55; i++) dp[i] = 2*dp[i-1] + (1LL << (i-1));
printf("%lld\n", count_one(B) - count_one(A-1));
return 0;
}
ll count_one(ll N) {
ll res = 0;
for(int i=54; i>0; i--) {
ll MSB = N & (1LL <<(i-1));
if(MSB) {
res += dp[i-1] + (N - MSB + 1);
N -= MSB;
}
}
return res;
}

View File

@ -0,0 +1,3 @@
export {};
const s = require("fs").readFileSync(0).toString().trim();
console.log(":fan::fan::fan:\n" + ":fan::" + s + "::fan:" + "\n:fan::fan::fan:\n");