コード例 #1
0
def p53():
    u = Utils()
    mat, val = u.binom(100, 100)
    total = 0
    for r in range(len(mat)):
        for c in range(len(mat[0])):
            if mat[r][c] > 10 ** 6:
                total += 1
    print total
コード例 #2
0
ファイル: p101.py プロジェクト: hpRamirez/project_euler
# Clearly no BOPs exist for k ≥ 4.
#
# By considering the sum of FITs generated by the BOPs
# (indicated in red above), we obtain 1 + 15 + 58 = 74.
#
# Consider the following tenth degree polynomial generating
# function:
#
# u_n = 1 − n + n^2 − n^3 + n^4 − n^5 + n^6 − n^7 + n^8 − n^9
# + n^10.
# Find the sum of FITs for the BOPs.

from utils import Utils

u_ = Utils()
m, val = u_.binom(11, 11)


def u(n):
    return n ** 10 - n ** 9 + n ** 8 - n ** 7 + n ** 6 - n ** 5 + n ** 4 - n ** 3 + n ** 2 - n + 1


U = [u(j) for j in range(1, 12)]


def fit(n):
    l = [((-1) ** (p + (n % 2))) * m[n][p - 1] * U[p - 1] for p in range(1, n + 1)]
    return sum(l)


def p101():
コード例 #3
0
def p15():
    u = Utils()
    print u.binom(40, 20)