1 #include <iostream> 2 using namespace std; 3 long long n, k; 4 int main() 5 { 6 cin >> n >> k; 7 long long l = 0, r = k, mid; 8 while (l < r) 9 { 10 mid = (l + r) / 2; 11 long long s = mid * k - (mid - 1) * (mid + 2) / 2; 12 if (s < n) 13 l = mid + 1; 14 else 15 r = mid; 16 } 17 mid = (l + r) / 2; 18 if (mid * k - (mid - 1) * (mid + 2) / 2 < n) 19 cout << -1 << endl; 20 else 21 cout << mid << endl; 22 return 0; 23 }