Skip to main content

Posts

Showing posts with the label pair cube

Pair cube [BASIC]

Company:Adobe Question: Given N, count all ‘a’ and ‘b’ that satisfy the condition a^3 + b^3 = N. Input: The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains integer n. Output: Count all 'a' and 'b' that satisfy the above equation. Constraints: 1<=T<=10^5 1<=n<=10^5 Example: Input: 2 9 28 Output: 2 2 Code: import java.util.*; import java.lang.*; import java.io.*; class GFG { public static void main (String[] args) { Scanner sc=new Scanner(System.in); int tc=sc.nextInt(); for(int i=0;i<tc;i++) {     int c=0;     double x=sc.nextInt();     for(int j=0;j<=x;j++)     {         for(int k=1;k<=x;k++)         {             double l=Math.pow(j,3) + Math.pow(k,3);    ...