Submission #1604369
Source Code Expand
// #include {{{ #include <array> #include <vector> #include <deque> #include <queue> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <string> #include <algorithm> #include <numeric> #include <functional> #include <iterator> #include <tuple> #include <utility> #include <random> #include <limits> #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cstdint> #include <cassert> #ifdef DEBUG #include <fmt/format.h> #endif // }}} using namespace std; // macros {{{ template<typename T, size_t N> constexpr size_t NELEMS(T (&)[N]) { return N; } template<typename InputIt> void PRINT_RANGE(InputIt first, InputIt last) { for(; first != last; ++first) cout << *first << (first==last ? "" : " "); cout << "\n"; } template<typename T> void PRINT_MATRIX(T mat, size_t nr, size_t nc) { for(size_t r = 0; r < nr; ++r) { for(size_t c = 0; c < nc; ++c) { cout << mat[r][c] << (c==nc-1 ? "" : " "); } cout << "\n"; } } #define FOR(i, start, end) for(int i = (start); i < (end); ++i) #define REP(i, n) FOR(i, 0, n) // }}} // types {{{ using ll = int64_t; using ull = uint64_t; // }}} template<typename T> T ceilpow2(T n) { assert(n >= 0); if(n == 0) return T(1); int r = static_cast<int>(floor(log2(static_cast<long double>(n)))) + 1; return T(1) << r; } template<typename T> T floorpow2(T n) { assert(n > 0); int r = static_cast<int>(floor(log2(n))); return T(1) << r; } uint32_t flp2(uint32_t n) { assert(n > 0); n = n | (n >> 1); n = n | (n >> 2); n = n | (n >> 4); n = n | (n >> 8); n = n | (n >> 16); return n - (n >> 1); } uint64_t flp2(uint64_t n) { assert(n > 0); n = n | (n >> 1); n = n | (n >> 2); n = n | (n >> 4); n = n | (n >> 8); n = n | (n >> 16); n = n | (n >> 32); return n - (n >> 1); } uint32_t clp2(uint32_t n) { if(n == 0) return 1; --n; n = n | (n >> 1); n = n | (n >> 2); n = n | (n >> 4); n = n | (n >> 8); n = n | (n >> 16); return n + 1; } uint64_t clp2(uint64_t n) { if(n == 0) return 1; --n; n = n | (n >> 1); n = n | (n >> 2); n = n | (n >> 4); n = n | (n >> 8); n = n | (n >> 16); n = n | (n >> 32); return n + 1; } ull A, B; void solve() { if(A == B) { cout << 1 << "\n"; return; } cout << floor(log2(static_cast<double>(0b11111111111111111111111111111111111111111111111111111111111))) << "\n"; cout << floor(log2(static_cast<long double>(0b11111111111111111111111111111111111111111111111111111111111))) << "\n"; #ifdef DEBUG fmt::print("A:\t{:b}\n", A); fmt::print("B:\t{:b}\n", B); fmt::print("A^B:\t{:b}\n", A^B); #endif //ull T2 = ceilpow2(A ^ B); ull T2 = flp2(A ^ B) << 1; A &= T2-1; B &= T2-1; ull T = T2 >> 1; ull xmin = A; ull xmax = T-1; //ull K = ceilpow2(B & (T-1)); ull BL = B & (T-1); ull K = BL == 0 ? 1 : flp2(B & (T-1)) << 1; ull ymin = T; ull ymax = T + K - 1; ull xymin = T+A; ull xymax = 2*T - 1; #ifdef DEBUG fmt::print("A:\t{:b}\n", A); fmt::print("B:\t{:b}\n", B); fmt::print("T2:\t{:b}\n", T2); fmt::print("T:\t{:b}\n", T); fmt::print("K:\t{:b}\n", K); fmt::print("xmin:\t{:b}\n", xmin); fmt::print("xmax:\t{:b}\n", xmax); fmt::print("ymin:\t{:b}\n", ymin); fmt::print("ymax:\t{:b}\n", ymax); fmt::print("xymin:\t{:b}\n", xymin); fmt::print("xymax:\t{:b}\n", xymax); #endif ull ans = xmax - xmin + 1; if(ymax < xymin) { ans += ymax - ymin + 1; ans += xymax - xymin + 1; } else { ans += xymax - ymin + 1; } cout << ans << "\n"; } int main() { cin >> A >> B; solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - A or...or B Problem |
User | yumsiim |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 3883 Byte |
Status | WA |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 900 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | WA | 1 ms | 256 KB |
02.txt | WA | 1 ms | 256 KB |
03.txt | WA | 1 ms | 256 KB |
04.txt | WA | 1 ms | 256 KB |
05.txt | WA | 1 ms | 256 KB |
06.txt | WA | 1 ms | 256 KB |
07.txt | WA | 1 ms | 256 KB |
08.txt | WA | 1 ms | 256 KB |
09.txt | WA | 1 ms | 256 KB |
10.txt | WA | 1 ms | 256 KB |
11.txt | WA | 1 ms | 256 KB |
12.txt | WA | 1 ms | 256 KB |
13.txt | WA | 1 ms | 256 KB |
14.txt | WA | 1 ms | 256 KB |
15.txt | WA | 1 ms | 256 KB |
16.txt | WA | 1 ms | 256 KB |
17.txt | WA | 1 ms | 256 KB |
18.txt | WA | 1 ms | 256 KB |
19.txt | WA | 1 ms | 256 KB |
20.txt | WA | 1 ms | 256 KB |
21.txt | WA | 1 ms | 256 KB |
22.txt | WA | 1 ms | 256 KB |
23.txt | WA | 1 ms | 256 KB |
24.txt | WA | 1 ms | 256 KB |
25.txt | WA | 1 ms | 256 KB |
26.txt | WA | 1 ms | 256 KB |
27.txt | WA | 1 ms | 256 KB |
28.txt | WA | 1 ms | 256 KB |
29.txt | WA | 1 ms | 256 KB |
30.txt | AC | 1 ms | 256 KB |
31.txt | WA | 1 ms | 256 KB |
32.txt | WA | 1 ms | 256 KB |
33.txt | WA | 1 ms | 256 KB |
34.txt | WA | 1 ms | 256 KB |
35.txt | WA | 1 ms | 256 KB |
36.txt | WA | 1 ms | 256 KB |
37.txt | WA | 1 ms | 256 KB |
38.txt | WA | 1 ms | 256 KB |
39.txt | WA | 1 ms | 256 KB |
40.txt | WA | 1 ms | 256 KB |
41.txt | WA | 1 ms | 256 KB |
42.txt | WA | 1 ms | 256 KB |
43.txt | WA | 1 ms | 256 KB |
44.txt | WA | 1 ms | 256 KB |
45.txt | WA | 1 ms | 256 KB |
46.txt | WA | 1 ms | 256 KB |
47.txt | WA | 1 ms | 256 KB |
48.txt | WA | 1 ms | 256 KB |
49.txt | WA | 1 ms | 256 KB |
50.txt | WA | 1 ms | 256 KB |
51.txt | AC | 1 ms | 256 KB |
52.txt | WA | 1 ms | 256 KB |
53.txt | WA | 1 ms | 256 KB |
54.txt | WA | 1 ms | 256 KB |
55.txt | WA | 1 ms | 256 KB |
56.txt | WA | 1 ms | 256 KB |
s1.txt | WA | 1 ms | 256 KB |
s2.txt | WA | 1 ms | 256 KB |
s3.txt | WA | 1 ms | 256 KB |