結果

問題 No.685 Logical Operations
ユーザー maroon_kurimaroon_kuri
提出日時 2018-05-11 23:18:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,191 bytes
コンパイル時間 2,175 ms
コンパイル使用メモリ 174,468 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-10 17:51:07
合計ジャッジ時間 2,892 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll=int64_t;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"{";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

const int mod=1000000007;
void add(int&a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}

map<pi,int> memo1,memo2,memo3;
/*int calc1(int a,int b){
	return 0;
}
**/
int calc2(int a,int b){
	if(a==0&&b==0)return 0;
	if(memo2.count(pi(a,b)))return memo2[pi(a,b)];
	int res=0;
	cerr<<a<<" "<<b<<" "<<res<<endl;
	add(res,calc2(a/2,b/2));
	cerr<<a<<" "<<b<<" "<<res<<endl;
	if(a>0){
		add(res,1);
		add(res,calc2((a-1)/2,b/2));
	}
	cerr<<a<<" "<<b<<" "<<res<<endl;
	if(b>0){
		add(res,1);
		add(res,calc2(a/2,(b-1)/2));
	}
	cerr<<a<<" "<<b<<" "<<res<<endl;
	if(a>0&&b>0)add(res,calc2((a-1)/2,(b-1)/2));
	cerr<<a<<" "<<b<<" "<<res<<endl;
	return memo2[pi(a,b)]=res;
}
int calc3(int a,int b){
	if(a==0&&b==0)return 0;
	if(memo3.count(pi(a,b)))return memo3[pi(a,b)];
	int res=0;
	add(res,calc3(a/2,b/2));
	if(a>0)add(res,calc3((a-1)/2,b/2));
	if(b>0)add(res,calc3(a/2,(b-1)/2));
	if(a>0&&b>0)add(res,calc2((a-1)/2,(b-1)/2));
	cerr<<a<<" "<<b<<" "<<res<<endl;
	return memo3[pi(a,b)]=res;
}

signed main(){
	int n=read();
	print(calc3(n,n)/2);
}
0