Help me in solving CHEFPRODUCT problem

My issue

Plz help to resolve error

My code

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		  Scanner scanner = new Scanner(System.in);
        long T = scanner.nextInt();  // Read the number of test cases

        for (long i = 0; i < T; i++) {
            long N = scanner.nextLong();  // Read N
          double sqrtN = Math.sqrt(N);
          
       long  result =0 ;
       
    if (N % 2 == 1) {  // Odd N
       result = (long)(sqrtN)+1  ;  // Round up to nearest integer
    }else{  
           result=(long)(sqrtN);}
     result /= 2;
    System.out.println(result);
        }
	}
}

Problem Link: Chef Product Practice Coding Problem - CodeChef

@deepak_5047
your logic looks fine, may be failing for some edge cases.
plzz refer the following solution

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
        int t=sc.nextInt();
        while(t-->0){
            long n=sc.nextLong();
            long x=new BigInteger(String.valueOf(n)).sqrt().longValue();
            if(n%2==0)
                System.out.println(x/2);
            else
                System.out.println((x+1)/2);
        }

	}
}

why you use String.value(n) ? you convert into string & how to calculate sqrt of String.