Computer Science, asked by komal9158, 2 days ago

Example
Input
9
23 1 8 56 27 67 64 125 232
Output
5

Answers

Answered by shubham280206
0
Ok but in what Bro or who so ever u are
Answered by shilpa85475
0

Input

9

23 1 8 56 27 67 64 125 232

Output

5

Explanation:

import java.util.Scanner;

public class abc {

public static boolean dimens_is_cube(int n) {

int i=1;

boolean result = false;

while(i<=n) {

 if(i*i*i == n) {

  result = true;

  break;

 }

 i++;

}

return result;

}

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

 

int numDimensions = scan.nextInt();

int[] dimens = new int[numDimensions];

for(int i=0;i<numDimensions;i++) {

 dimens[i] = scan.nextInt();

}

int perfect_cube = 0;  //initialize counter

 

for(int i=0;i<numDimensions;i++) {

 if(dimens_is_cube(dimens[i])) {

  perfect_cube++;

 }

}

System.out.println(perfect_cube);  //print result

}

Similar questions