Submission #3601562
Source Code Expand
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;
#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;
ll N, memo[77][5][5];
ll dfs(int d,int xm,int am){
if(d<0) return 1;
if(memo[d][xm][am]>=0) return memo[d][xm][am];
ll ret=0;
if(N&(1LL<<d)){
ret+=dfs(d-1,1,min(2,am*2+1));
}else{
ret+=dfs(d-1,xm,min(2,am*2));
}
if(N&(1LL<<d)){
ret+=dfs(d-1,xm,min(2,am*2));
}else{
if(am&&xm) ret+=dfs(d-1,xm,min(2,am*2-1));
}
if(am){
if(N&(1LL<<d)){
ret+=dfs(d-1,1,min(2,am*2-1));
}else{
ret+=dfs(d-1,xm,min(2,am*2-2));
}
}
return memo[d][xm][am]=ret%MOD;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin>>N;
mem(memo,-1);
cout1(dfs(60,0,0));
}
Submission Info
Submission Time |
|
Task |
D - Xor Sum |
User |
mensan_fukuhara |
Language |
C++14 (GCC 5.4.1) |
Score |
600 |
Code Size |
1662 Byte |
Status |
AC |
Exec Time |
1 ms |
Memory |
256 KB |
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 |
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 |