K. Profact

Codeforces
IDCF10079K
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Alice is bored out of her mind by her math classes. She craves for something much more exciting. That is why she invented a new type of numbers, the #cf_span(class=[tex-font-style-underline], body=[profacts]). Alice calls a positive integer number a profact if it can be expressed as a product of one or several factorials. Just today Alice received n bills. She wonders whether the costs on the bills are profact numbers. But the numbers are too large, help Alice check this! The first line contains a single integer n, the number of bills (1 ≤ n ≤ 105). Each of the next n lines contains a single integer ai, the cost on the i-th bill (1 ≤ ai ≤ 1018). Output n lines, on the i-th line output the answer for the number ai. If the number ai is a profact, output "_YES_", otherwise output "_NO_". A #cf_span(class=[tex-font-style-underline], body=[factorial]) is any number that can be expressed as 1·2·3·...·k, for some positive integer k, and is denoted by k!. ## Input The first line contains a single integer n, the number of bills (1 ≤ n ≤ 105). Each of the next n lines contains a single integer ai, the cost on the i-th bill (1 ≤ ai ≤ 1018). ## Output Output n lines, on the i-th line output the answer for the number ai. If the number ai is a profact, output "_YES_", otherwise output "_NO_". [samples] ## Note A #cf_span(class=[tex-font-style-underline], body=[factorial]) is any number that can be expressed as 1·2·3·...·k, for some positive integer k, and is denoted by k!.
**Definitions** Let $ \mathcal{F} = \{ k! \mid k \in \mathbb{Z}^+ \} $ be the set of factorials. A *profact* is a positive integer that can be expressed as a product of one or more elements from $ \mathcal{F} $, i.e., $$ \mathcal{P} = \left\{ \prod_{i=1}^m f_i \mid m \geq 1, \, f_i \in \mathcal{F} \right\}. $$ **Given** Let $ n \in \mathbb{Z} $, $ 1 \leq n \leq 10^5 $, be the number of bills. Let $ A = (a_1, a_2, \dots, a_n) $, where each $ a_i \in \mathbb{Z} $, $ 1 \leq a_i \leq 10^{18} $, be the sequence of bill costs. **Objective** For each $ a_i \in A $, determine whether $ a_i \in \mathcal{P} $. Output "YES" if $ a_i $ is a profact, otherwise output "NO".
API Response (JSON)
{
  "problem": {
    "name": "K. Profact",
    "description": {
      "content": "Alice is bored out of her mind by her math classes. She craves for something much more exciting. That is why she invented a new type of numbers, the #cf_span(class=[tex-font-style-underline], body=[pr",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10079K"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Alice is bored out of her mind by her math classes. She craves for something much more exciting. That is why she invented a new type of numbers, the #cf_span(class=[tex-font-style-underline], body=[pr...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ \\mathcal{F} = \\{ k! \\mid k \\in \\mathbb{Z}^+ \\} $ be the set of factorials.  \nA *profact* is a positive integer that can be expressed as a product of one or more elements from $...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments