Setsubun

AtCoder
IDabc443_b
Time2000ms
Memory256MB
Difficulty
At the annual Setsubun festival, one eats the same number of beans as their age. Takahashi-kun does not eat beans at any other time. He is $N$ years old at this year's Setsubun ($0$ years later). At the earliest, how many years later will he have eaten a total of $K$ or more beans from this year onward (including this year)? He is immortal, so he will eventually have eaten a total of $K$ or more beans from this year onward. ## Constraints * All input values are integers. * $1 \le N,K \le 10^8$ ## Input The input is given from Standard Input in the following format: $N$ $K$ [samples]
Samples
Input #1
4 43
Output #1
6

*   At Setsubun $0$ years later, Takahashi-kun eats $4$ beans, totaling $4$ beans from this year onward.
*   At Setsubun $1$ year later, he eats $5$ beans, totaling $9$ beans from this year onward.
*   At Setsubun $2$ years later, he eats $6$ beans, totaling $15$ beans from this year onward.
*   At Setsubun $3$ years later, he eats $7$ beans, totaling $22$ beans from this year onward.
*   At Setsubun $4$ years later, he eats $8$ beans, totaling $30$ beans from this year onward.
*   At Setsubun $5$ years later, he eats $9$ beans, totaling $39$ beans from this year onward.
*   At Setsubun $6$ years later, he eats $10$ beans, totaling $49$ beans from this year onward.

At Setsubun $6$ years later, he will have eaten a total of $43$ or more beans, so output $6$.
Input #2
100000000 100000000
Output #2
0

The number of beans eaten this year alone may reach $K$ or more.
Input #3
1234 12345678
Output #3
3886
API Response (JSON)
{
  "problem": {
    "name": "Setsubun",
    "description": {
      "content": "At the annual Setsubun festival, one eats the same number of beans as their age. Takahashi-kun does not eat beans at any other time.   He is $N$ years old at this year's Setsubun ($0$ years later). At",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc443_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "At the annual Setsubun festival, one eats the same number of beans as their age. Takahashi-kun does not eat beans at any other time.  \nHe is $N$ years old at this year's Setsubun ($0$ years later).\nAt...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments