Problem: Akari has n kinds of flowers, one of each kind.  She is going to choose one or more of these flowers to make a bouquet.  However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.  How many different bouquets are there that Akari can make?  Find the count modulo (10^9 + 7).  Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.

Submission attempts (in order):
n, a, b = map(int, input().split())

from operator import mul
from functools import reduce
import math

flg = (a == n-b)
rep = math.ceil(n/2)
MOD = 10**9+7
memo = 0

def modpow(a: int, p: int, mod: int) -> int:
    
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mod_mul, range(n, n - r, -1), 1)
    denom = reduce(mod_mul, range(1, r + 1), 1)
    return numer*pow(denom, MOD-2, MOD)%MOD
  
def mod_mul(a, b):
  return mul(a%MOD, b%MOD)%MOD

s = 0
ans = modpow(2, n, MOD)
if flg:
  ans = ans - combinations_count(n, a)
else:
  ans = (ans - combinations_count(n,a))%MOD - combinations_count(n,b)
print(ans%MOD)

n, a, b = map(int, input().split())

from operator import mul
from functools import reduce
import math

flg = (a == n-b)
rep = math.ceil(n/2)
MOD = 10**9+7
memo = 0

def modpow(a: int, p: int, mod: int) -> int:
    
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mod_mul, range(n, n - r, -1), 1)
    denom = reduce(mod_mul, range(1, r + 1), 1)
    return numer*pow(denom, MOD-2, MOD)%MOD
  
def mod_mul(a, b):
  return mul(a%MOD, b%MOD)%MOD

s = 0
ans = modpow(2, n, MOD)-1
if flg:
  ans = ans - combinations_count(n, a)
else:
  ans = (ans - combinations_count(n,a))%MOD - combinations_count(n,b)
print(ans%MOD)

n, a, b = map(int, input().split())

from operator import mul
from functools import reduce
import math

flg = (a == n-b)
rep = math.ceil(n/2)
MOD = 10**9+7
memo = 0

def modpow(a: int, p: int, mod: int) -> int:
    
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mod_mul, range(n, n - r, -1), 1)
    denom = reduce(mod_mul, range(1, r + 1), 1)
    return numer*pow(denom, MOD-2, MOD)%MOD
  
def mod_mul(a, b):
  return mul(a%MOD, b%MOD)%MOD

s = 0
ans = modpow(2, n, MOD)+1
if flg:
  ans = ans - combinations_count(n, a)
else:
  ans = (ans - combinations_count(n,a))%MOD - combinations_count(n,b)
print(ans%MOD)

n, a, b = map(int, input().split())

from operator import mul
from functools import reduce
import math

flg = (a == n-b)
rep = math.ceil(n/2)
MOD = 10**9+7
memo = 0

def modpow(a: int, p: int, mod: int) -> int:
    
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mod_mul, range(n, n - r, -1), 1)
    denom = reduce(mod_mul, range(1, r + 1), 1)
    return numer*pow(denom, MOD-2, MOD)%MOD
  
def mod_mul(a, b):
  return mul(a%MOD, b%MOD)%MOD

s = 0
ans = modpow(2, n, MOD)-1
if flg:
  ans = ans - 2*combinations_count(n, a)%MOD
else:
  ans = (ans - combinations_count(n,a))%MOD - combinations_count(n,b)
print(ans%MOD)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted