For each K
for j in range ( self . k + 1 ) : NEW_LINE INDENT val = self . f ( self . k , j ) NEW_LINE val1 = ( pow ( self . A [ i ] , self . k - j ) * pre [ i - 1 ] [ j ] ) NEW_LINE val = val * val1 NEW_LINE if j % 2 == 0 : NEW_LINE INDENT ans = ans + val NEW_LINE DEDENT else : NEW_LINE INDENT ans = ans - val NEW_LINE DEDENT DEDENT ans = 2 * ans NEW_LINE