阅读98 返回首页    go 阿里云 go 技术社区[云栖]


1060: NEW RDSP MODE I

1060: NEW RDSP MODE I

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 33  Solved: 9
[Submit][Status][Web Board]

Description

Little A has became fascinated with the game Dota recently, but he is not a good player. In all the modes, the rdsp Mode is popular on online, in this mode, little A always loses games if he gets strange heroes, because, the heroes are distributed randomly.

Little A wants to win the game, so he cracks the code of the rdsp mode with his talent on programming. The following description is about the rdsp mode:

There are N heroes in the game, and they all have a unique number between 1 and N. At the beginning of game, all heroes will be sorted by the number in ascending order. So, all heroes form a sequence One.

These heroes will be operated by the following stages M times:

1.Get out the heroes in odd position of sequence One to form a new sequence Two;

2.Let the remaining heroes in even position to form a new sequence Three;

3.Add the sequence Two to the back of sequence Three to form a new sequence One.

After M times' operation, the X heroes in the front of new sequence One will be chosen to be Little A's heroes.

The problem for you is to tell little A the numbers of his heroes.

Input

There are several test cases.

Each case contains three integers N (1<=N<1,000,000), M (1<=M<100,000,000), X(1<=X<=20).

Proceed to the end of file.

Output

For each test case, output X integers indicate the number of heroes. There is a space between two numbers.

The output of one test case occupied exactly one line.

Sample Input

5 1 2
5 2 2

Sample Output

2 4
4 3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <vector>
using namespace std;
#define MAX_LEN 26
int main()
{
    long v[MAX_LEN+1];
    long hero, half;
    long long opNum;
    int x, i, loop;
    int remainder;
 
    while (cin >> hero >> opNum >> x)
    {
         for (i = 1; i <= x; i++)
         {
             v[i] = i;
         }
         half = hero / 2;
         loop = 0;
 
         for (i = 1; i <= opNum; i++)
         {
             if (v[1] <= half)
             {
                 v[1] *= 2;
             }
             else
             {
                 if (hero % 2 == 0)//偶数
                    v[1] = v[1] * 2 - hero - 1;
                 else
                    v[1] = v[1] * 2 - hero;
             }
 
             if (1 == v[1])
             {
                 loop = i;
                 break;
             }
         }
 
         if (loop != 0)
         {
             remainder = opNum % loop;
         }
         else
             remainder = opNum;
 
         for (i = 1; i <= x; i++)
         {
             v[i] = i;
         }
         for (i = 1; i <= remainder; i++)
         {
             for (int j = 1; j <= x; j++)
             {
                 if (v[j] <= half)
                     v[j] *= 2;
                 else
                 {
                      if (hero % 2 == 0)
                         v[j] = v[j] * 2 - hero - 1;
                      else
                         v[j] = v[j] * 2 - hero;
                  }
 
              }
         }
 
         for (i = 1; i <= x; i++)
         {
             if (i != 1)
                cout << " ";
             cout << v[i];
         }
         cout << endl;
    }
 
    return 0;
}
 
/**************************************************************
    Problem: 1060
    User: 1006440533
    Language: C++
    Result: Accepted
    Time:124 ms
    Memory:1272 kb
****************************************************************/


最后更新:2017-04-02 15:14:59

  上一篇:go 1053: You are my brother
  下一篇:go 1077: Slash