Submission #7025264


Source Code Expand

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
 
using namespace std;
 
#define LL long long
const int mod = 1e9 + 7;
LL dp[66][2][2],L, R; 
 
LL dfs(int x, bool Left, bool Right, bool zero) {
    if(x < 0) return 1; 
    if(dp[x][Left][Right] >= 0 && !zero) 
        return dp[x][Left][Right]; 
    LL ans = 0;
    int l = 0, r = 1; 
    if(Left) l = L >> x & 1; 
    if(Right) r = R >> x & 1; 
    for(int i = l ; i <= 1 ; i++) {
        for (int j = i ; j <= r ; j++) {
            if (j == 1 && zero) {
                if(i == 1) ans += dfs(x-1, Left && i == l, Right && j == r, zero && j == 0); 
            }
            else ans += dfs(x-1, Left && i == l, Right && j == r, zero && j == 0); 
        }
    }
    ans %= mod; 
    if(!zero) dp[x][Left][Right] = ans; 
    return ans; 
}
int main() {
    scanf("%lld%lld",  & L,  & R); 
    memset(dp, -1, sizeof(dp)); 
    printf("%lld \n", dfs(60, 1, 1, 1)); 
    //system("pause");
    return 0; 
}

Submission Info

Submission Time
Task F - Coincidence
User L_Y_T
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1019 Byte
Status AC
Exec Time 1 ms
Memory 256 KiB

Compile Error

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

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 23
Set Name Test Cases
Sample a01, a02, a03
All a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23
Case Name Status Exec Time Memory
a01 AC 1 ms 256 KiB
a02 AC 1 ms 256 KiB
a03 AC 1 ms 256 KiB
b04 AC 1 ms 256 KiB
b05 AC 1 ms 256 KiB
b06 AC 1 ms 256 KiB
b07 AC 1 ms 256 KiB
b08 AC 1 ms 256 KiB
b09 AC 1 ms 256 KiB
b10 AC 1 ms 256 KiB
b11 AC 1 ms 256 KiB
b12 AC 1 ms 256 KiB
b13 AC 1 ms 256 KiB
b14 AC 1 ms 256 KiB
b15 AC 1 ms 256 KiB
b16 AC 1 ms 256 KiB
b17 AC 1 ms 256 KiB
b18 AC 1 ms 256 KiB
b19 AC 1 ms 256 KiB
b20 AC 1 ms 256 KiB
b21 AC 1 ms 256 KiB
b22 AC 1 ms 256 KiB
b23 AC 1 ms 256 KiB