Submission #1218136


Source Code Expand

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <vector>
#include <deque>
#include <functional>
#include <iterator>
#include <utility>
#include <bitset>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <cctype>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a) - 1; i >= (b); --i)
#define SZ(x) ((int)x.size())
#define openfile {freopen("inp.txt","rt",stdin);freopen("out.txt","wt",stdout);}
#define debug 0

template <typename T> inline void next_int(T &x) {
	x = 0; char c; bool neg = false;
	while (!isdigit(c = getchar())) if (c == '-') neg = true;
	do x = x*10 + c - 48; while (isdigit(c = getchar()));
	if (neg) x = -x;
}

template <typename T> inline void write_int(T x, char last = 0) {
	if (x < 0) putchar('-'), x = abs(x);
	char tmp[20]; int cnt = 0;
	while (x >= 10) tmp[cnt++] = x % 10 + 48, x /= 10;
	tmp[cnt] = x + 48;
	FORD(i, cnt, 0) putchar(tmp[i]);
	if (last) putchar(last);
}

const ll base = (int)1e9+7;
ll n, dp[65][2][2][2];

int getbit(ll x, int idx) { return (x >> idx) & 1; }

ll solve(int i, int j, int k, int l) {
	if (i > 60) {
		if (!j) return !k && !l;
		return 0;
	}
	if (dp[i][j][k][l] != -1) return dp[i][j][k][l];
	ll &ret = dp[i][j][k][l];
	ret = 0;
	//0 and 0
	int nj = 0, nk = k, nl = l;
	if (j) {
		nj = 0;
		if (getbit(n, i) == 1) nk = k, nl = 0;
		else nk = 1, nl = l;
	} else {
		nj = 0;
		if (getbit(n, i) == 0) nk = k, nl = l;
		else nk = 0, nl = 0;
	}
	ret += solve(i + 1, nj, nk, nl), ret %= base;
	//(0 and 1) or (1 and 0)
	if (!j) {
		nj = 0;
		if (getbit(n, i) == 1) nk = k, nl = l;
		else nk = 1, nl = 1;
	} else {
		nj = 1;
		if (getbit(n, i) == 0) nk = k, nl = 1;
		else nk = 0, nl = l;
	}
	ret += solve(i + 1, nj, nk, nl), ret %= base;
	//1 and 1
	if (j) {
		nj = 1;
		if (getbit(n, i) == 1) nk = k, nl = 0;
		else nk = 1, nl = l;
	} else {
		nj = 1;
		if (getbit(n, i) == 0) nk = k, nl = l;
		else nk = 0, nl = 0;
	}
	ret += solve(i + 1, nj, nk, nl), ret %= base;
	return ret;
}

int main() {
	scanf("%lld", &n);
	memset(dp, -1, sizeof(dp));
	printf("%lld", solve(0, 0, 0, 0));
	return 0;
}

Submission Info

Submission Time
Task D - Xor Sum
User MasterMind0108
Language C++14 (GCC 5.4.1)
Score 600
Code Size 2652 Byte
Status AC
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:107:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
                   ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_max_01.txt, subtask_1_rand_01.txt, subtask_1_rand_02.txt, subtask_1_rand_03.txt, subtask_1_rand_04.txt, subtask_1_rand_05.txt, subtask_1_small_rand_01.txt, subtask_1_small_rand_02.txt, subtask_1_small_rand_03.txt, subtask_1_small_rand_04.txt, subtask_1_small_rand_05.txt, subtask_1_specific_01.txt, subtask_1_specific_02.txt, subtask_1_specific_03.txt, subtask_1_specific_04.txt, subtask_1_specific_05.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_max_01.txt AC 1 ms 256 KB
subtask_1_rand_01.txt AC 1 ms 256 KB
subtask_1_rand_02.txt AC 1 ms 256 KB
subtask_1_rand_03.txt AC 1 ms 256 KB
subtask_1_rand_04.txt AC 1 ms 256 KB
subtask_1_rand_05.txt AC 1 ms 256 KB
subtask_1_small_rand_01.txt AC 1 ms 256 KB
subtask_1_small_rand_02.txt AC 1 ms 256 KB
subtask_1_small_rand_03.txt AC 1 ms 256 KB
subtask_1_small_rand_04.txt AC 1 ms 256 KB
subtask_1_small_rand_05.txt AC 1 ms 256 KB
subtask_1_specific_01.txt AC 1 ms 256 KB
subtask_1_specific_02.txt AC 1 ms 256 KB
subtask_1_specific_03.txt AC 1 ms 256 KB
subtask_1_specific_04.txt AC 1 ms 256 KB
subtask_1_specific_05.txt AC 1 ms 256 KB