結果

問題 No.2067 ±2^k operations
ユーザー SSRSSSRS
提出日時 2022-09-02 22:05:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 400 ms / 2,000 ms
コード長 1,210 bytes
コンパイル時間 1,788 ms
コンパイル使用メモリ 177,328 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 21:40:29
合計ジャッジ時間 11,349 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 362 ms
6,940 KB
testcase_02 AC 367 ms
6,940 KB
testcase_03 AC 369 ms
6,944 KB
testcase_04 AC 379 ms
6,944 KB
testcase_05 AC 368 ms
6,944 KB
testcase_06 AC 366 ms
6,944 KB
testcase_07 AC 386 ms
6,944 KB
testcase_08 AC 380 ms
6,944 KB
testcase_09 AC 373 ms
6,944 KB
testcase_10 AC 381 ms
6,940 KB
testcase_11 AC 377 ms
6,940 KB
testcase_12 AC 390 ms
6,944 KB
testcase_13 AC 396 ms
6,944 KB
testcase_14 AC 391 ms
6,944 KB
testcase_15 AC 381 ms
6,940 KB
testcase_16 AC 398 ms
6,940 KB
testcase_17 AC 400 ms
6,944 KB
testcase_18 AC 383 ms
6,940 KB
testcase_19 AC 364 ms
6,944 KB
testcase_20 AC 367 ms
6,944 KB
testcase_21 AC 362 ms
6,944 KB
testcase_22 AC 364 ms
6,944 KB
testcase_23 AC 367 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int T;
  cin >> T;
  for (int i = 0; i < T; i++){
    long long N;
    cin >> N;
    N++;
    vector<vector<vector<long long>>> cnt(61, vector<vector<long long>>(2, vector<long long>(16, 0)));
    vector<vector<vector<long long>>> sum(61, vector<vector<long long>>(2, vector<long long>(16, 0)));
    cnt[60][0][0] = 1;
    for (int j = 59; j >= 0; j--){
      for (int k = 0; k < 2; k++){
        for (int l = 0; l < 16; l++){
          for (int m = 0; m < 2; m++){
            if (!(k == 0 && (N >> j & 1) == 0 && m == 1)){
              int k2 = k;
              if ((N >> j & 1) == 1 && m == 0){
                k2 = 1;
              }
              int l2 = ((l & 7) << 1) | m;
              if (l == 13 && m == 0){
                l2 = 6;
              }
              cnt[j][k2][l2] += cnt[j + 1][k][l];
              sum[j][k2][l2] += sum[j + 1][k][l];
              if (l % 4 != 3 && l != 13 && m == 1){
                sum[j][k2][l2] += cnt[j + 1][k][l];
              }
            }
          }
        }
      }
    }
    long long ans = 0;
    for (int j = 0; j < 16; j++){
      ans += sum[0][1][j];
    }
    cout << ans << endl;
  }
}
0