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

30146번 - Dividing Stones 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 1024 MB3010834.783%

문제

There are N stones, which can be divided into some piles arbitrarily. Let the value of each division be equal to the product of the number of stones in all the piles modulo P. How many possible distinct values are possible for a given N and P?

입력

The first line contains the number of test cases T. T lines follow, one corresponding to each test case, containing 2 integers: N and P.

출력

Output T lines, each line containing the required answer for the corresponding test case.

제한

  • T ≤ 20
  • 2 ≤ N ≤ 70
  • 2 ≤ P ≤ 109

예제 입력 1

2
3 1000
5 1000

예제 출력 1

3
6

힌트

In the first test case, the possible ways of division are (1,1,1), (1,2), (2,1) and (3) which have values 1, 2, 2, 3 and hence, there are 3 distinct values.

In the second test case, the numbers 1 to 6 constitute the answer and they can be obtained in the following ways:

  • 1=1*1*1*1*1
  • 2=2*1*1*1
  • 3=3*1*1
  • 4=4*1
  • 5=5
  • 6=2*3

출처

ICPC > Regionals > Asia West Continent > India > The 2010 ACM-ICPC Asia Amritapuri Regional Contest I번

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

출처

대학교 대회

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

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