Submission #1071908


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)

#define X first
#define Y second

template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

int Cb[65][65];
signed main() {
	const int mod = 1e9 + 7;
	Cb[0][0] = 1;
	rep(i, 64) rep(j, 64) {
		(Cb[i + 1][j] += Cb[i][j]) %= mod;
		(Cb[i + 1][j + 1] += Cb[i][j]) %= mod;
	}
	int N; cin >> N;
	int sum = ((N % 2 + 1 + N + 1) / 2) % mod * (N / 2 + 1) % mod;
	int bs = 0;
	int ovs = 0;
	for (int i = 63; i >= 0; i--) if((N >> i) & 1){
		(ovs += (1 << max(bs - 1, 0ll))) %= mod;
		rep(j, 1, i + 1) {
			(ovs += (Cb[i][j] * ((1 << (bs + j - 1)) % mod)) % mod) %= mod;
		}
		bs++;
	}
	// a xor b == N
	(ovs += (1 << max(bs - 1, 0ll))) %= mod;

	cout << (sum - ovs + N + 1) % mod << endl;
	system("pause");
}

Submission Info

Submission Time
Task D - Xor Sum
User tosaka2
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1686 Byte
Status WA
Exec Time 4 ms
Memory 504 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:56:17: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
  system("pause");
                 ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 1
WA × 2
AC × 5
WA × 11
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 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 4 ms 504 KB
sample_02.txt WA 4 ms 504 KB
sample_03.txt WA 4 ms 504 KB
subtask_1_max_01.txt WA 4 ms 504 KB
subtask_1_rand_01.txt WA 4 ms 504 KB
subtask_1_rand_02.txt WA 4 ms 504 KB
subtask_1_rand_03.txt WA 4 ms 504 KB
subtask_1_rand_04.txt WA 4 ms 504 KB
subtask_1_rand_05.txt WA 4 ms 504 KB
subtask_1_small_rand_01.txt WA 4 ms 504 KB
subtask_1_small_rand_02.txt WA 4 ms 504 KB
subtask_1_small_rand_03.txt WA 4 ms 504 KB
subtask_1_small_rand_04.txt WA 4 ms 504 KB
subtask_1_small_rand_05.txt WA 4 ms 504 KB
subtask_1_specific_01.txt AC 4 ms 504 KB
subtask_1_specific_02.txt AC 4 ms 504 KB
subtask_1_specific_03.txt AC 4 ms 504 KB
subtask_1_specific_04.txt AC 4 ms 504 KB
subtask_1_specific_05.txt AC 4 ms 504 KB