Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Uri/Beecrowd problem no - 1150 solution in Java

import java.util.Scanner;

public class Main{
    public static void main (String[] args) {
        Scanner obj = new Scanner(System.in);
        int X,Z,counter = 1,c = 0,i;
        X = obj.nextInt();
        Z = obj.nextInt();
        
        while(Z <= X){
            Z = obj.nextInt();
            for (i = X; i <= Z; i++){
                c += i;
                if(c > Z){
                    break;
                }else{
                    counter++;
                }
            }
        }
        System.out.println(counter);
    }
}
Source by www.beecrowd.com.br #
 
PREVIOUS NEXT
Tagged: #problem #solution #Java
ADD COMMENT
Topic
Name
6+6 =