P. The Only Level

Codeforces
IDCF10253P
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
A secret agent... to be one you have pushed both your physical and intellectual capacities, immersing yourself in the art of espionage. It is now time to prove your worth. Your name isn't Mario but you end up falling down from a pipe. You find an elephant in a room. It speaks. You expect a Sphinx to give out a riddle in this scenario, but the elephant gives you no time to be confused as it tells you: "If you want to be a spy, you must pass the test." After a moment's hesitation, you find the words to reply. "Yes, this is what I came here for. But is there anything else that I must do?" "No, this is the only level," the elephant assures you. It gives you the test: " The *digital sum* of an integer in base $b$ is the sum of its digits when it is written in base $b$. The *digital root* of an integer in base $b$ is the unique digit obtained by repeatedly computing the digital sum in base $b$ until only one digit remains. Let $f_b (k)$ be the digital root of the integer $k$ in base $b$. We say that the pair $(k, b)$ is *cool* if and only if $(f_b (0), f_b (k), f_b (2 k), \\dots, f_b ((b -1) k))$ is a permutation of $(0, 1, 2, \\dots, b -1)$. Given $k$ and $b$, is $(k, b)$ a cool pair? " The first line of input contains $t$, the number of test cases. Each test case consists of a single line containing two space-separated integers $k$ and $b$. *Constraints* $1 <= t <= 10^5$ $1 <= k <= 10^(15)$ $2 <= b <= 10^(15)$ For each test case, output a single line containing the string: ## Input The first line of input contains $t$, the number of test cases. Each test case consists of a single line containing two space-separated integers $k$ and $b$. *Constraints*$1 <= t <= 10^5$$1 <= k <= 10^(15)$$2 <= b <= 10^(15)$ ## Output For each test case, output a single line containing the string: "_COOL_" (without the quotes) if $(k, b)$ is a cool pair; "_NOT COOL_" (without the quotes) if $(k, b)$ is not a cool pair. [samples]
**Definitions** Let $ b \in \mathbb{Z}_{\geq 2} $, $ k \in \mathbb{Z}_{\geq 1} $. Let $ f_b(k) $ denote the digital root of $ k $ in base $ b $, defined as the single digit obtained by iteratively summing the base-$ b $ digits of a number until a single digit remains. **Constraints** 1. $ 1 \leq t \leq 10^5 $ 2. For each test case: - $ 1 \leq k \leq 10^{15} $ - $ 2 \leq b \leq 10^{15} $ **Objective** For given $ k $ and $ b $, determine whether the sequence $$ (f_b(0), f_b(k), f_b(2k), \dots, f_b((b-1)k)) $$ is a permutation of $ (0, 1, 2, \dots, b-1) $. Output "Yes" if the pair $ (k, b) $ is *cool*, otherwise "No".
API Response (JSON)
{
  "problem": {
    "name": "P. The Only Level",
    "description": {
      "content": "A secret agent... to be one you have pushed both your physical and intellectual capacities, immersing yourself in the art of espionage. It is now time to prove your worth. Your name isn't Mario but y",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10253P"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A secret agent... to be one you have pushed both your physical and intellectual capacities, immersing yourself in the art of espionage. It is now time to prove your worth.\n\nYour name isn't Mario but y...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ b \\in \\mathbb{Z}_{\\geq 2} $, $ k \\in \\mathbb{Z}_{\\geq 1} $.  \nLet $ f_b(k) $ denote the digital root of $ k $ in base $ b $, defined as the single digit obtained by iteratively...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments