結果
| 問題 |
No.2939 Sigma Popcount Problem
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2024-10-18 21:33:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 742 ms / 2,000 ms |
| コード長 | 808 bytes |
| コンパイル時間 | 4,299 ms |
| コンパイル使用メモリ | 253,256 KB |
| 最終ジャッジ日時 | 2025-02-24 20:29:53 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000000LL
int main(){
int _t;
cin>>_t;
rep(_,_t){
long long n;
cin>>n;
vector dp(2,vector<long long>(2,0));
dp[0][0] = 1;
for(int i=39;i>=0;i--){
vector ndp(2,vector<long long>(2,0));
rep(j,2){
rep(k,2){
rep(l,3){
int nj = j,nk = k;
if(l && ((n>>i)&1)==0 && j==0)continue;
if(l==0 && ((n>>i)&1)){
nj = 1;
}
if(k&&l==2)continue;
if(l==2)nk = 1;
ndp[nj][nk] += dp[j][k];
}
}
}
swap(dp,ndp);
}
long long ans = dp[0][1] + dp[1][1];
cout<<ans<<endl;
}
return 0;
}
沙耶花