贤鱼的刷题日常(数据结构队列学习)-2406:Card Stacking--题目详解

🏆今日学习目标:
🍀例题讲解2406:Card Stacking
✅创作者:贤鱼
⏰预计时间:25分钟
🎉个人主页:贤鱼的个人主页
🔥专栏系列:c++
🍁贤鱼的个人社区,欢迎你的加入 贤鱼摆烂团

请添加图片描述

2406:Card Stacking

题目

总时间限制: 20000ms 单个测试点时间限制: 1000ms 内存限制: 65536kB
描述
Bessie is playing a card game with her N-1 (2 <= N <= 100) cow friends using a deck with K (N <= K <= 100,000; K is a multiple of N) cards. The deck contains M = K/N “good” cards and K-M “bad” cards. Bessie is the dealer and, naturally, wants to deal herself all of the “good” cards. She loves winning.

Her friends suspect that she will cheat, though, so they devise a dealing system in an attempt to prevent Bessie from cheating. They tell her to deal as follows:

  1. Start by dealing the card on the top of the deck to the cow to her right

  2. Every time she deals a card, she must place the next P (1 <= P <= 10) cards on the bottom of the deck; and

  3. Continue dealing in this manner to each player sequentially in a counterclockwise manner

Bessie, desperate to win, asks you to help her figure out where she should put the “good” cards so that she gets all of them. Notationally, the top card is card #1, next card is #2, and so on.
输入

  • Line 1: Three space-separated integers: N, K, and P
    输出
  • Lines 1…M: Positions from top in ascending order in which Bessie should place “good” cards, such that when dealt, Bessie will obtain all good cards.
    样例输入
    3 9 2
    样例输出
    3
    7
    8
    提示
    INPUT DETAILS:

Bessie is playing cards with two cow friends and a deck of 9 cards. She must place two cards on the bottom of the deck each time she deals one.

OUTPUT DETAILS:

Bessie should put the “good” cards in positions 3, 7, and 8. The cards will be dealt as follows; the card numbers are “position in original deck”:

                                      Card Deck         P1      P2    Bessie
 Initial configuration           1 2 3 4 5 6 7 8 9  - - -   - - -   - - -
 Deal top card [1] to Player 1   2 3 4 5 6 7 8 9    1 - -   - - -   - - -
 Top card to bottom (#1 of 2)    3 4 5 6 7 8 9 2    1 - -   - - -   - - -
 Top card to bottom (#2 of 2)    4 5 6 7 8 9 2 3    1 - -   - - -  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

贤鱼不闲

一分钱也是爱!!!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值