Ejemplo n.º 1
0
def cheat():
    'decimalモジュールの有効桁数を操作するチート?'
    ans = 0
    dec = decimal.Decimal
    for n in range(1, 100):
        if not intlib.is_square(n):
            ans += sum(int(d) for d in str(dec(n)**dec(.5))[:101] if d != '.')
    return ans
Ejemplo n.º 2
0
def cheat():
    'decimalモジュールの有効桁数を操作するチート?'
    ans = 0
    dec = decimal.Decimal
    for n in range(1, 100):
        if not intlib.is_square(n):
            ans += sum(int(d) for d in str(dec(n) ** dec(.5))[:101]
                       if d != '.')
    return ans
Ejemplo n.º 3
0
def main():
    ans = 0
    max_x = 0
    for d in range(1, 1001):
        if is_square(d): continue
        x, y = solve_pell(d)
        #print(d, (x, y))
        if x > max_x:
            ans = d
            max_x = x
    return ans
Ejemplo n.º 4
0
def main():
    _max = 10**4
    odd_iter = (2*n + 1 for n in itertools.count(1))
    primes = intlib.primes(_max)
    primes_set = set(primes) #membership判定用set
    
    for n in odd_iter:
        if n > _max: return 'Not found.'
        if n in primes_set: continue
        flag = True
        for p in primes:
            if p > n: break
            if intlib.is_square((n - p)//2):
                flag = False
                break
        if flag:
            return n
Ejemplo n.º 5
0
def is_pentagonal(x):
    if intlib.is_square(1 + 24 * x) and int((1 + 24 * x) ** 0.5) % 6 == 5:
        return (int((1 + 24 * x) ** 0.5) + 1) // 6
    return 0
Ejemplo n.º 6
0
def is_pseudo_pentagonal(x):
    if intlib.is_square(1 + 24 * x) and int((1 + 24 * x) ** 0.5) % 6 == 1:
        return (int((1 + 24 * x) ** 0.5) - 1) // 6
    return 0
Ejemplo n.º 7
0
def main():
    return sum((1 for n in range(2, 10001)
                if not is_square(n) and cycle(n) % 2))