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

5293번 - Dividing the Pirate Hoard 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB17712610168.707%

문제

After raiding an island N pirates end up with M coins. After the raid everybody gathers coins and puts them together in a community pile, to be divided the next day. During the night one pirate decides to take his share himself. He sneaks his way to the hoard and divides the M coins into N equal piles, with K coins left over. He keeps the extra K coins for himself, hides his pile of coins, and puts the other piles of coins back into a single pile. The other pirates then do the same thing one at a time, each dividing the remaining coins into N piles, taking one pile, and keeping any extra coins to keep the remaining piles even.

Given the number of pirates and coins, find out how many coins each pirate will have his own hidden pile (his equal-sized pile plus remaining coins) and how many coins are left in the community pile at the end of the night.

입력

The input will be the number of coins, followed by the number of pirates.

출력

The output should be the number of coins received by each pirate from largest to smallest (separated by spaces), followed by the total number of coins remaining in the hoard on a second line.

제한

예제 입력 1

12 2

예제 출력 1

6 3
3

예제 입력 2

10 3

예제 출력 2

4 2 2
2

힌트

출처

School > University of Maryland High School Programming Contest > HSPC 2007 2번

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

출처

대학교 대회

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

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