From 06b9cd27822b9aa49644c93ee403fc57b141abad Mon Sep 17 00:00:00 2001 From: songyc macbook Date: Thu, 15 Jan 2026 22:50:44 +0900 Subject: [PATCH] baekjoon 20260115 --- code_study/Baekjoon/c/9527.c | 32 ++++++++++++++++++++++++++++++++ code_study/Baekjoon/ts/14581.ts | 3 +++ 2 files changed, 35 insertions(+) create mode 100644 code_study/Baekjoon/c/9527.c create mode 100644 code_study/Baekjoon/ts/14581.ts diff --git a/code_study/Baekjoon/c/9527.c b/code_study/Baekjoon/c/9527.c new file mode 100644 index 0000000..ffdc77a --- /dev/null +++ b/code_study/Baekjoon/c/9527.c @@ -0,0 +1,32 @@ +#include + +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; +} \ No newline at end of file diff --git a/code_study/Baekjoon/ts/14581.ts b/code_study/Baekjoon/ts/14581.ts new file mode 100644 index 0000000..0a36d4b --- /dev/null +++ b/code_study/Baekjoon/ts/14581.ts @@ -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"); \ No newline at end of file