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

31371번 - Superfactorial numeral system 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB54231659.259%

문제

On the most perfect of all planets i1c5l various numeral systems are being used during programming contests. In the second division they use a superfactorial numeral system. In this system any positive integer is presented as a linear combination of numbers converse to factorials:

$$\frac{p}{q} = a_1 + \frac{a_2}{2!} + \frac{a_3}{3!} + \ldots + \frac{a_n}{n!},円.$$

Here $a_1$ is non-negative integer, and integers $a_k$ for $k \ge 2$ satisfy 0ドル \le a_k < k$. The nonsignificant zeros in the tail of the superfactorial number designation $\frac{p}{q}$ are rejected. The task is to find out how the rational number $\frac{p}{q}$ is presented in the superfactorial numeral system.

입력

Single line contains two space-separated integers $p$ and $q$ (1ドル \le p \le 10^6,ドル 1ドル \le q \le 10^6$).

출력

Single line should contain a sequence of space-separated integers $a_1, a_2, \ldots, a_n,ドル forming a number designation $\frac{p}{q}$ in the superfactorial numeral system. If several solution exist, output any of them.

제한

예제 입력 1

1 2

예제 출력 1

0 1

예제 입력 2

2 10

예제 출력 2

0 0 1 0 4

예제 입력 3

10 2

예제 출력 3

5

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 11: Grand Prix of Tatarstan > Division 2 P번

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

출처

대학교 대회

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

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