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