Logo
(追記) (追記ここまで)

24962번 - It’s Surely Complex 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
30 초 (추가 시간 없음) 1024 MB52211533.333%

문제

As you know, a complex number is often represented as the sum of a real part and an imaginary part. 3ドル + 2i$ is such an example, where 3ドル$ is the real part, 2ドル$ is the imaginary part, and $i$ is the imaginary unit.

Given a prime number $p$ and a positive integer $n,ドル your program for this problem should output the product of all the complex numbers satisfying the following conditions.

  • Both the real part and the imaginary part are non-negative integers less than or equal to $n$.
  • At least one of the real part and the imaginary part is not a multiple of $p$.

For instance, when $p = 3$ and $n = 1,ドル the complex numbers satisfying the conditions are 1ドル$ ($= 1 + 0i$), $i$ ($= 0 + 1i$), and 1ドル + i$ ($= 1 + 1i$), and the product of these numbers, that is, 1ドル × i × (1 + i)$ is $-1 + i$.

입력

The input consists of a single test case of the following format.

$p ,円 n$

$p$ is a prime number less than 5ドル × 10^5$. $n$ is a positive integer less than or equal to 10ドル^{18}$.

출력

Output two integers separated by a space in a line. When the product of all the complex numbers satisfying the given conditions is $a + bi,ドル the first and the second integers should be $a$ modulo $p$ and $b$ modulo $p,ドル respectively. Here, $x$ modulo $y$ means the integer $z$ between 0ドル$ and $y - 1,ドル inclusive, such that $x - z$ is divisible by $y$.

As exemplified in the main section, when $p = 3$ and $n = 1,ドル the product to be calculated is $-1 + i$. However, since $-1$ modulo 3ドル$ is 2ドル,ドル 2ドル$ and 1ドル$ are displayed in Sample Output 1.

제한

예제 입력 1

3 1

예제 출력 1

2 1

예제 입력 2

5 5

예제 출력 2

0 0

예제 입력 3

499979 1000000000000000000

예제 출력 3

486292 0

힌트

출처

ICPC > Regionals > Asia Pacific > Japan > ICPC 2021 Asia Yokohama Regional F번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /