Partition

AtCoder
IDabc112_d
Time2000ms
Memory256MB
Difficulty
You are given integers $N$ and $M$. Consider a sequence $a$ of length $N$ consisting of positive integers such that $a_1 + a_2 + ... + a_N$ = $M$. Find the maximum possible value of the greatest common divisor of $a_1, a_2, ..., a_N$. ## Constraints * All values in input are integers. * $1 \leq N \leq 10^5$ * $N \leq M \leq 10^9$ ## Input Input is given from Standard Input in the following format: $N$ $M$ [samples]
Samples
Input #1
3 14
Output #1
2

Consider the sequence $(a_1, a_2, a_3) = (2, 4, 8)$. Their greatest common divisor is $2$, and this is the maximum value.
Input #2
10 123
Output #2
3
Input #3
100000 1000000000
Output #3
10000
API Response (JSON)
{
  "problem": {
    "name": "Partition",
    "description": {
      "content": "You are given integers $N$ and $M$. Consider a sequence $a$ of length $N$ consisting of positive integers such that $a_1 + a_2 + ... + a_N$ = $M$. Find the maximum possible value of the greatest commo",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc112_d"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given integers $N$ and $M$.\nConsider a sequence $a$ of length $N$ consisting of positive integers such that $a_1 + a_2 + ... + a_N$ = $M$. Find the maximum possible value of the greatest commo...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments