QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#5091. Midwinter Problem

統計

In the middle of winter, djq and dxm are playing cards.

The two players first agree on two positive integers $n$ and $k$, such that $n$ is even and $n \geq 2k$. Then, each player receives $k$ cards. The $i$-th card ($1 \leq i \leq k$) in dxm's hand has the positive integer $n+(2i-1)$ written on it, and the $i$-th card in djq's hand has the positive integer $n-(2i-1)$ written on it. Note that the cards held by both players together form $2k$ consecutive odd integers.

The game consists of $k$ rounds. In each round, both players play one card from their remaining hand, and played cards cannot be retrieved. If the numbers on the two cards are coprime, djq scores one point; otherwise, dxm scores one point. After all rounds are completed, both players calculate their total scores.

djq already knows that in the $i$-th round, dxm will play the $i$-th card from his hand. Now he wants to know:

  • His highest possible score;
  • A strategy for playing his cards to achieve this maximum score.

Please write a program to help him!

Input

A single line containing two positive integers $n$ and $k$.

Output

The first line should output an integer $s$, representing the maximum possible score for djq.

The next $k$ lines should each output an integer, where the $i$-th line contains the integer $p_i$, representing the index of the card djq should play in the $i$-th round.

Examples

Input 1

10 3

Output 1

3
3
1
2

Note 1

dxm's cards are $[11, 13, 15]$ in order, and djq's cards are $[9, 7, 5]$ in order. djq only needs to play his cards in the order $[5, 9, 7]$ to get all $3$ points.

Implementation Details

This problem uses a Special Judge. To ensure the Special Judge works correctly, you must ensure:

  • The first line of your output is an integer in $[0, k]$.
  • The next $k$ lines each contain an integer in $[1, k]$.
  • The output contains no other content.

Violating these specifications may result in receiving no points.

Provided the output follows the specifications, scoring is as follows:

  • If both $s$ and the output strategy are correct, you receive full marks for the test case.
  • If $s$ is correct but the output strategy is incorrect, you receive $15\%$ of the marks for the test case.
  • Otherwise, you will receive no marks.

Constraints

For all data, $1 \leq k \leq 10^6$, $2k \leq n \leq 10^{100}$, and $n$ is guaranteed to be even.

This problem consists of several subtasks. For each subtask, your score is the minimum score among all test cases within that subtask.

Subtask ID $k$ $n$ Score
$1$ $\leq 10$ $\leq 10^9$ $5$
$2$ $\leq 20$ $5$
$3$ $\leq 200$ $15$
$4$ $\leq 2 \times 10^3$ $10$
$5$ $n=2k$ $25$
$6$ $\leq 10^5$ $\leq 10^9$ $10$
$7$ $15$
$8$ $15$

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.