Except One

시간 제한1초메모리 제한2048 MB

요약
소수 p와 제외할 값 k가 주어질 때, {1,...,p-1}에서 k를 뺀 집합의 모든 t원소 부분집합의 곱의 합을 p로 나눈 나머지를 구한다.
난이도

어려움10점 중 8점

유형
조합론, 수학, 정수론
정답자
아직 제출이 없습니다

문제

You are given three integers pp, kk, tt, where pp is a prime number.

The set SS is defined as follows: S=x∣x∈N, 1≤x≤p−1, x≠kS = \\{x \mid x \in N, \ 1 \leq x \leq p - 1, \ x \neq k \\}.

Find the sum of the products of all tt-element subsets of SS, modulo pp.

입력

The first line contains three integers pp, kk, tt (pp is a prime number; 1≤k≤p−11 \leq k \leq p-1; 1≤t≤p−21 \leq t \leq p-2; p≤109p \leq 10^9).

출력

Print the sum of the products of all tt-element subsets of SS, modulo pp.

예제2

  1. 예제 1

    입력
    7 5 3
    
    예상 출력
    1
    
  2. 예제 2

    입력
    11 6 7
    
    예상 출력
    3