B. Yet Another Convolution

Codeforces
IDCF10235B
Time6000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You are given an integer array $a_1, \\dots, a_n$ and an integer array $b_1, \\dots, b_n$. You have to calculate the array $c_1, \\dots, c_n$ defined as follows: $$c_k = \max\limits_{\gcd(i,j) = k} |a_i - b_j|\text{.}$$ The first line of input contains a single integer $n$ ($1 <= n <= 10^5$). The second line of input contains $n$ integers $a_1, \\dots, a_n$ ($1 <= a_i <= 10^9$). The third line of input contains $n$ integers $b_1, \\dots, b_n$ ($1 <= b_i <= 10^9$). Output $n$ integers $c_1, \\dots, c_n$. ## Input The first line of input contains a single integer $n$ ($1 <= n <= 10^5$).The second line of input contains $n$ integers $a_1, \\dots, a_n$ ($1 <= a_i <= 10^9$).The third line of input contains $n$ integers $b_1, \\dots, b_n$ ($1 <= b_i <= 10^9$). ## Output Output $n$ integers $c_1, \\dots, c_n$. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $, and let $ A = (a_1, \dots, a_n) $, $ B = (b_1, \dots, b_n) $ be sequences of integers. Define $ C = (c_1, \dots, c_n) $, where for each $ k \in \{1, \dots, n\} $: **Objective** $$ c_k = \max_{\substack{1 \le i,j \le n \\ \gcd(i,j) = k}} |a_i - b_j| $$
API Response (JSON)
{
  "problem": {
    "name": "B. Yet Another Convolution",
    "description": {
      "content": "You are given an integer array $a_1, \\\\dots, a_n$ and an integer array $b_1, \\\\dots, b_n$. You have to calculate the array $c_1, \\\\dots, c_n$ defined as follows: $$c_k = \\max\\limits_{\\gcd(i,j) = k} ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 6000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10235B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given an integer array $a_1, \\\\dots, a_n$ and an integer array $b_1, \\\\dots, b_n$.\n\nYou have to calculate the array $c_1, \\\\dots, c_n$ defined as follows:\n\n$$c_k = \\max\\limits_{\\gcd(i,j) = k} ...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $, and let $ A = (a_1, \\dots, a_n) $, $ B = (b_1, \\dots, b_n) $ be sequences of integers.  \nDefine $ C = (c_1, \\dots, c_n) $, where for each $ k \\in \\{1, \\do...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments