結果

問題 No.2067 ±2^k operations
ユーザー 沙耶花沙耶花
提出日時 2022-09-02 22:30:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,256 bytes
コンパイル時間 4,615 ms
コンパイル使用メモリ 267,488 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-27 22:06:44
合計ジャッジ時間 8,418 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
13,756 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 2000000000000000001



int main(){
	
	int _t;
	cin>>_t;
	
	rep(_,_t){
		
		long long N;
		cin>>N;
		
		vector dp(2,vector(60,vector<long long>(60,0)));
		dp[0][0][2] = 1;
		
		for(int i=59;i>=0;i--){
			vector ndp(2,vector(60,vector<long long>(60,0)));
			rep(j,2){
				rep(k,60){
					rep(l,60){
						if(dp[j][k][l]==0)continue;
						
						rep(m,2){
							int nj = j,nk = 59,nl = 59;
							
							if(j==0 && ((N>>i)&1)==0 && m==1)continue;
							if(((N>>i)&1) && m==0)nj = 1;
							if(m==0){
								nk = min(nk,k);
								nl = min(nl,l+1);
								nk = min(nk,l);
							}
							else{
								nk = min(nk,k+1);
								nl = min(nl,l);
								nl = min(nl,k+2);
							}
							
							ndp[nj][nk][nl] += dp[j][k][l];
						}
						
						
					}
				}
			}
			swap(dp,ndp);
			
		}
		
		long long ans = 0;
		rep(i,2){
			rep(j,60){
				rep(k,60){
					//if(dp[i][j][k])cout<<i<<','<<j<<','<<k<<endl;
					
					ans += dp[i][j][k] * (long long) min(j,k);
				}
			}
		}
		
		cout<<ans<<endl;
		
	}
	
    return 0;
}
0