Submission #1071923
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)
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; }; }
#define X first
#define Y second
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 dp[65][3];
signed main() {
const int mod = 1e9 + 7;
int N; cin >> N;
dp[0][0] = 1;
int b = log2(N);
for (int i = 0; i <= b; i++) rep(j, 3) {
if (N >> (b - i) & 1) {
(dp[i + 1][min(j * 2 + 1, 2)] += dp[i][j]) %= mod;
(dp[i + 1][min(j * 2, 2)] += dp[i][j]) %= mod;
if (j * 2 - 1 >= 0)(dp[i + 1][min(j * 2 - 1, 2)] += dp[i][j]) %= mod;
} else {
(dp[i + 1][min(j * 2, 2)] += dp[i][j]) %= mod;
if (j * 2 - 1 >= 0) (dp[i + 1][min(j * 2 - 1, 2)] += dp[i][j]) %= mod;
if (j * 2 - 2 >= 0) (dp[i + 1][min(j * 2 - 2, 2)] += dp[i][j]) %= mod;
}
}
cout << (dp[b + 1][0] + dp[b + 1][1] + dp[b + 1][2]) % mod << endl;
system("pause");
}
Submission Info
Submission Time
2017-01-21 12:05:27+0900
Task
D - Xor Sum
User
tosaka2
Language
C++14 (GCC 5.4.1)
Score
600
Code Size
1730 Byte
Status
AC
Exec Time
7 ms
Memory
756 KB
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:50: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
600 / 600
Status
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
7 ms
756 KB
sample_02.txt
AC
4 ms
504 KB
sample_03.txt
AC
4 ms
504 KB
subtask_1_max_01.txt
AC
4 ms
504 KB
subtask_1_rand_01.txt
AC
4 ms
504 KB
subtask_1_rand_02.txt
AC
4 ms
504 KB
subtask_1_rand_03.txt
AC
4 ms
504 KB
subtask_1_rand_04.txt
AC
4 ms
504 KB
subtask_1_rand_05.txt
AC
4 ms
504 KB
subtask_1_small_rand_01.txt
AC
4 ms
504 KB
subtask_1_small_rand_02.txt
AC
4 ms
504 KB
subtask_1_small_rand_03.txt
AC
4 ms
504 KB
subtask_1_small_rand_04.txt
AC
4 ms
504 KB
subtask_1_small_rand_05.txt
AC
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