UVA10170




Sample Input:
1 6
3 10
3 14

Sample Output:
3
5
6




大意:有一間客源不會斷的旅館 一次只能有一團人住

N個人住進去 會在裡面待N天 要你求在第N天的時候是幾人團住在裡面

ex: N=4 那麼如果住進去是1號會住到4號 下一團會從5號開始住




import java.util.Scanner;

public class UVA10170 {

  public static void main(String[] args) {

   Scanner sc = new Scanner(System.in);

   while (sc.hasNext()) {

    int start = sc.nextInt();

    long end = sc.nextLong();

    long count = 0, i = 0, max = 0;

    i = start;

    while (count < end) {

     count += i;

     if (max < i)
     max = i;

     else
     break;

     i++;

    }
   System.out.println(max);

   }

   sc.close();
 }

}