hihoCoder太阁最新面经算法竞赛10 register

Ended

Participants:138

Verdict:Accepted
Score:100 / 100
Submitted:2016-07-29 16:09:01

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <bits/stdc++.h>
template<typename T> inline bool Gosper_next(T& x) {
    if (!x) return false;
    unsigned long long lowbit = x & (-(long long)(x));
    unsigned long long ripple = lowbit + x;
    if (!ripple) return false;
    x = ripple | (((x ^ ripple) >> 2) / lowbit);
    return true;
}
inline int _7(int i) { assert(i < 32); return (1 << i) - 1; }
int main() {
    int n;
    scanf("%d", &n);
    int x = _7(n);
    do {
        int mm = x & _7(6);
        int hh = x >> 6 & _7(5);
        if (mm < 60 && hh < 24) {
            printf("%02d:%02d\n", hh, mm);
        }
    } while (Gosper_next(x) && x >> 11 == 0);
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX