B-Number

Bruce Lee has recently become the sensei (Master) of the very institute which taught him everything…

Click here to read the complete problem statement.


If you need help solving this problem, mention your approach and ask specific questions. Please avoid sharing your code and asking the Community to figure out “what’s wrong”.

What’s wrong with my java code??

import java.util.Scanner;

public class Solution {
	public static void main(String[] args) {		
		Scanner scanner = new Scanner(System.in);
		int x = scanner.nextInt(),j=0;
		if(x>=1 && x<=20000) {
			for(int i=1;i<=x;i++) {
				j=scanner.nextInt();
				if(j>=1&&j<=231) {
					System.out.println(j/3+1);
				}
			}
		}
	}
}

@InanClass5 It seems the input specification had the incorrectly formatted constraints. Instead of 2^31, it was being shown was 231.

You can update your Java code to fix this.

Side note: you do not need to check for these constraints in your code when trying to solve them.

Thanks I solved it.

1 Like