結果
問題 | No.2067 ±2^k operations |
ユーザー |
![]() |
提出日時 | 2022-09-02 22:21:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 537 bytes |
コンパイル時間 | 743 ms |
コンパイル使用メモリ | 66,652 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-16 04:12:15 |
合計ジャッジ時間 | 1,580 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 23 |
ソースコード
#include <iostream>#include <algorithm>using namespace std;int main() {cin.tie(0);ios_base::sync_with_stdio(false);int T;cin >> T;long long dp[58];dp[0] = 1;for (int i = 1; i <= 57; i++) {dp[i] = dp[i - 1] * 2 + (1LL << i) / 3;}for (int testcase = 1; testcase <= T; testcase++) {long long N;cin >> N;long long answer = 0;while (N != 0) {int level = 63 - __builtin_clzll(N);N -= (1LL << level);answer += dp[level] + min(N, (2LL << level) / 3);}cout << answer << '\n';}return 0;}