結果

問題 No.685 Logical Operations
ユーザー PulmnPulmn
提出日時 2017-08-18 11:17:40
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 514 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 56,764 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 15:42:57
合計ジャッジ時間 1,480 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;
typedef long long ll;

const ll M=60,mod=1e9+7;

ll N;

ll res=0,dp[4],b=0;

int main(){
	cin>>N;
	for(int i=M;i>=0;i--){
		ll DP[4];
		if(N&1ll<<i){
			DP[0]=(dp[0]+!b)%mod;
			DP[1]=(2*dp[0]+3*dp[1]+b)%mod;
			DP[2]=(dp[0]+2*dp[2])%mod;
			DP[3]=(dp[1]+2*dp[2]+4*dp[3])%mod;
			b=1;
		}
		else{
			DP[0]=2*dp[0]%mod;
			DP[1]=(3*dp[1]+b)%mod;
			DP[2]=2*dp[2]%mod;
			DP[3]=(dp[1]+4*dp[3])%mod;
		}
		for(int j=0;j<4;j++) dp[j]=DP[j];
	}
	cout<<(dp[2]+dp[3])%mod<<endl;
}
0