310124: CF1786A1. Non-alternating Deck (easy version)

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Non-alternating Deck (easy version)

题意翻译

Alice 有 $n$ 张牌,所有牌的颜色均一样。 Alice 准备把牌分给 Bob 和她自己。Alice 以这样的方式发牌:一张牌给 Alice,两张牌给 Bob,三张牌给 Bob,四张牌给 Alice,五张牌给 Alice,六张牌给 Bob,以此类推。当某一步没有足够的牌时,Alice 会将所有剩余的牌发给当前玩家,且停止发牌。 给出牌的张数 $n$,求每个玩家最后的牌数。 有多组数据。

题目描述

This is an easy version of the problem. In this version, all cards have the same color. Alice has $ n $ cards, each card is white, and the cards are stacked in a deck. Alice deals the cards to herself and to Bob, dealing at once several cards from the top of the deck in the following order: one card to herself, two cards to Bob, three cards to Bob, four cards to herself, five cards to herself, six cards to Bob, seven cards to Bob, eight cards to herself, and so on. In other words, on the $ i $ -th step, Alice deals $ i $ top cards from the deck to one of the players; on the first step, she deals the cards to herself and then alternates the players every two steps. When there aren't enough cards at some step, Alice deals all the remaining cards to the current player, and the process stops. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF1786A1/9b5c59f025613ef63ec148ccf27b2fa7eb55eceb.png) First Alice's steps in a deck of many cards.How many cards will Alice and Bob have at the end?

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 200 $ ). The description of the test cases follows The only line of each test case contains a single integer $ n $ ( $ 1 \le n \le 10^6 $ ) — the number of cards.

输出格式


For each test case print two integers — the number of cards in the end for each player — in this order: cards Alice has, cards Bob has.

输入输出样例

输入样例 #1

5
10
6
17
8
1000000

输出样例 #1

5 5
1 5
10 7
3 5
500202 499798

Input

题意翻译

Alice 有 $n$ 张牌,所有牌的颜色均一样。 Alice 准备把牌分给 Bob 和她自己。Alice 以这样的方式发牌:一张牌给 Alice,两张牌给 Bob,三张牌给 Bob,四张牌给 Alice,五张牌给 Alice,六张牌给 Bob,以此类推。当某一步没有足够的牌时,Alice 会将所有剩余的牌发给当前玩家,且停止发牌。 给出牌的张数 $n$,求每个玩家最后的牌数。 有多组数据。

Output

题目大意:
这个问题是“非交替牌组”问题的简单版本。在这个版本中,所有的牌颜色都是相同的。Alice有n张牌,每张牌都是白色的,并且牌堆叠在一起。Alice将牌发给自己和Bob,按照以下顺序一次发牌:第一张给自己,接下来两张给Bob,然后三张给Bob,四张给自己,五张给自己,六张给Bob,七张给Bob,八张给自己,以此类推。换句话说,在第i步,Alice从牌堆顶部发i张牌给某个玩家;在第一步,她给自己发牌,然后每两步交替一次玩家。当某一步骤牌不够时,Alice将所有剩余的牌发给当前玩家,并且过程停止。

输入输出数据格式:
每个测试包含多个测试案例。第一行包含测试案例的数量t(1≤t≤200)。接下来是每个测试案例的描述。

每个测试案例只有一行,包含一个整数n(1≤n≤10^6)——牌的数量。

对于每个测试案例,按顺序输出两个整数——每个玩家最后拥有的牌的数量——首先是Alice的牌数,然后是Bob的牌数。

输入输出样例:
输入样例 #1
```
5
10
6
17
8
1000000
```
输出样例 #1
```
5 5
1 5
10 7
3 5
500202 499798
```题目大意: 这个问题是“非交替牌组”问题的简单版本。在这个版本中,所有的牌颜色都是相同的。Alice有n张牌,每张牌都是白色的,并且牌堆叠在一起。Alice将牌发给自己和Bob,按照以下顺序一次发牌:第一张给自己,接下来两张给Bob,然后三张给Bob,四张给自己,五张给自己,六张给Bob,七张给Bob,八张给自己,以此类推。换句话说,在第i步,Alice从牌堆顶部发i张牌给某个玩家;在第一步,她给自己发牌,然后每两步交替一次玩家。当某一步骤牌不够时,Alice将所有剩余的牌发给当前玩家,并且过程停止。 输入输出数据格式: 每个测试包含多个测试案例。第一行包含测试案例的数量t(1≤t≤200)。接下来是每个测试案例的描述。 每个测试案例只有一行,包含一个整数n(1≤n≤10^6)——牌的数量。 对于每个测试案例,按顺序输出两个整数——每个玩家最后拥有的牌的数量——首先是Alice的牌数,然后是Bob的牌数。 输入输出样例: 输入样例 #1 ``` 5 10 6 17 8 1000000 ``` 输出样例 #1 ``` 5 5 1 5 10 7 3 5 500202 499798 ```

加入题单

算法标签: