E. Napoléon

Codeforces
IDCF10102E
Time1000ms
Memory64MB
Difficulty
English · Original
Formal · Original
In the world of chess, there is a good plan to start your game with which is “Napoléon plan”. “Napoléon plan” is commonly based on two pieces, (the queen and a bishop), using these two pieces you can guarantee the win after some moves if you are facing a beginner opponent or any way you can start your game with it to explore your opponent qualifications. Further, this plan can be used and applied in proceeding states of your game so you can disperse your opponent before you surprise him/her with a successful apply of “Napoléon plan” and saying your mortal word “checkmate”. The plan; substantially, says that you can checkmate your opponent king by constricting it with its allies, threatening it with your queen which is guarded; commonly, by your bishop. The picture displays a successful apply of “Napoléon plan”. Our problem goes in a further state of the game, when you need to get your bishop to the right state guarding your queen for a successful apply of the plan. Given the Current location of the bishop and its Target state in the form Xc, Yc, Xt, Yt starting the count from zero, tell the queen: the minimum number of squares that the bishop pass in the minimum moves assuming an empty chess board. The first line of input is the number of test cases 0<T<5000, the second line is an integer for the chessboard size 0<N<=20, then (2*T) lines follow. Each test case is two lines; the first line contains two integers 0<=Xc,Yc<N representing the current location of the bishop, the second line contains another two integers 0<=Xt,Yt<N representing the target location of the bishop. For each test case, print a line containing the minimum number of squares passed by the bishop on its way to the target location taking the minimal possible moves or print “can't reach!” in case of impossible to reach the target from the current location. ## Input The first line of input is the number of test cases 0<T<5000, the second line is an integer for the chessboard size 0<N<=20, then (2*T) lines follow. Each test case is two lines; the first line contains two integers 0<=Xc,Yc<N representing the current location of the bishop, the second line contains another two integers 0<=Xt,Yt<N representing the target location of the bishop. ## Output For each test case, print a line containing the minimum number of squares passed by the bishop on its way to the target location taking the minimal possible moves or print “can't reach!” in case of impossible to reach the target from the current location. [samples]
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case: - Let $ n \in \mathbb{Z} $ be the number of universities. - Let $ A = (a_1, a_2, \dots, a_n) $ be a sequence of positive integers, where $ a_i $ is the number of contestants from university $ i $. **Constraints** 1. $ 1 \leq T \leq 1000 $ 2. For each test case: - $ 1 \leq n \leq 1000 $ - $ 1 \leq a_i \leq 10^6 $ for all $ i \in \{1, \dots, n\} $ **Objective** Find integers $ k $ and $ m $ such that: - $ k $ is the greatest common divisor of all $ a_i $: $$ k = \gcd(a_1, a_2, \dots, a_n) $$ - $ m $ is the minimum total number of teams, where each team has exactly $ k $ contestants from the same university: $$ m = \sum_{i=1}^{n} \frac{a_i}{k} $$ Output $ (k, m) $.
API Response (JSON)
{
  "problem": {
    "name": "E. Napoléon",
    "description": {
      "content": "In the world of chess, there is a good plan to start your game with which is “Napoléon plan”.  “Napoléon plan” is commonly based on two pieces, (the queen and a bishop), using these two pieces you can",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10102E"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "In the world of chess, there is a good plan to start your game with which is “Napoléon plan”.  “Napoléon plan” is commonly based on two pieces, (the queen and a bishop), using these two pieces you can...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case:  \n- Let $ n \\in \\mathbb{Z} $ be the number of universities.  \n- Let $ A = (a_1, a_2, \\dots, a_n) $ be a se...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments