def get_divs(l):
    divs = set([1])
    for i in xrange(1, len(l) + 1):
        for j in list(ce(l, i)):
            divs.add(reduce(lambda x, y: x * y, j))
    for i in divs:
        print i,
Ejemplo n.º 2
0
def get_divs(l):
    divs = set([1])
    for i in xrange(1, len(l) + 1):
        for j in list(ce(l, i)):
            divs.add(reduce(lambda x, y: x * y, j))
    for i in divs:
        print i,
def solve(d, s):
    if len(d) == 1:
        return 0
    maxLen = 0
    for i in ce(d.iterkeys(), len(d) - 2):
        L = [k for k in s if k not in i]
        if isValidString(L):
            maxLen = max(maxLen, len(L))

    return maxLen
Ejemplo n.º 4
0
def combine_with_rep(string, num):
    for j in ce(sorted(string), num):
        print(''.join(j))
            saved[1] = en
    yield saved[1] - saved[0]

if __name__ == '__main__':
    from itertools import combinations as ce
    for _ in xrange(input()):
        N, L = map(int, raw_input().split())
        roads = []
        for _ in xrange(N):
            a, b = map(int, raw_input().split())
            roads.append((a, b))

        found = False

        for i in xrange(1, N + 1):
            for subRoad in ce(roads, i):
                if i == 1:
                    # subroad must be a single interval
                    if subRoad[0][1] - subRoad[0][0] == L:
                        found = True
                        break

                for roadLength in merge(subRoad):
                    if roadLength == L:
                        found = True
                        break
                if found:
                    break

            if found:
                break