Friday, April 24, 2015

UVa - 10170 - The Hotel with Infinite Rooms

#include <iostream>
#include <cstdio>
using namespace std;

int main(){
    long long S, D, Sum, temp;
    while(cin >> S >> D){
        Sum = 0, temp = S;
        while(1){
            Sum += S;
            S += 1;
            if(Sum >= D)break;
        }
        long long ans = S-1;
        cout << ans << endl;
    }
    return 0;
}

No comments:

Post a Comment