#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() {     long long x, y;     cin >> x >> y;     long long sum = x + y;     long long n = sqrt(2 * sum);     cout << n;     if (n * (n + 1) / 2 != sum) cout << -1 << endl;     else {         if (x <= n) cout << 1 << endl;         else {             int count = 0;             int t = n;             while (x > 0 && t > 0) {                 if (t <= x) {                     count += 1;                     x = x - t;                 }                 else { count += 1; break; }                 t--;             }             cout << count << endl;         }     }     return 0; }
点赞 评论

相关推荐

08-25 14:25
门头沟学院 Java
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务