Beispiel #1
0
from gcj import Problem
from gcj.utils import Timer


# Parser
def parser(fin):
    N = fin.readInt()
    return N


# Solver
def solver(data):
    N = data

    if N == 0:
        return 'INSOMNIA'

    i = 0
    digits = set()
    while len(digits) != 10:
        i += 1
        digits |= set(list(str(N * i)))

    return i * N


# Main
if __name__ == '__main__':
    with Timer('Problem A'):
        Problem(parser, solver).run()
Beispiel #2
0
        iS = []

        for s in [i for i, stal in enumerate(stals) if not stal]:
            iS.append(s)
            lS.append(LS(stals, s))
            rS.append(RS(stals, s))
        minLSRS = [min(lS[i], rS[i]) for i in xrange(len(iS))]
        maxLSRS = [max(lS[i], rS[i]) for i in xrange(len(iS))]
        minLSRSVal = max(minLSRS)
        i = minLSRS.index(minLSRSVal)
        if minLSRS.count(minLSRSVal) > 0:
            for j in xrange(len(iS)):
                if minLSRS[j] == minLSRSVal:
                    if maxLSRS[j] > maxLSRS[i]:
                        i = j

        stals[iS[i]] = 1

#    print stals
#    print lS,rS

    ans = '{0} {1}'.format(max(lS[i], rS[i]), min(lS[i], rS[i]))
    print ans
    return ans


# Main
if __name__ == '__main__':
    with Timer('Problem C'):
        Problem(parser, solver).run()
Beispiel #3
0
from gcj.utils import Timer, getFunctions


# Parser
def parser(fin):
    data = fin.readFloats()
    return data


# Solver


def solver(data):

    C, F, X = data
    P = 2.0
    T = 0.0
    M = 0.0

    while True:
        if X / P < (C / P + X / (P + F)):
            return '{0:.7f}'.format((T + X / P))
        T += C / P
        P += F


# Main
if __name__ == '__main__':
    with Timer('Problem B'):
        Problem(parser, solver, getFunctions(globals())).run()