(一)
public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int N = sc.nextInt(); int count=0; for(int i=1;i<=N;i++){ double pow = Math.pow(i, 3); double sqrt = Math.sqrt(pow); if((int)sqrt==sqrt){ count++; } } System.out.println(count++); } }
(二)
public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int N = sc.nextInt(); int M=sc.nextInt(); int count=0; sc.nextLine(); int[] arr=new int[N]; for(int i=0;i<N;i++){ arr[i] = sc.nextInt(); } for(int i=0;i<N;i++){ for(int j=i+1;j<N;j++) if(arr[i]+arr[j]==M){ count++; } } System.out.println(count); } }
(三)
public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int x = sc.nextInt(); int y=sc.nextInt(); //解二元一次方程组15*x + 10*y= 400 5*x + 10*y= 300 int M=(x-y)/10; int N=(3*y-x)/20; if(M<0){ System.out.print("不存在"); }else{ System.out.print(M+" "); } if(N<0){ System.out.println("不存在"); } else{ System.out.println(N); } } }
(四)
public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); String str= sc.nextLine(); String result=""; for(int i=0;i<str.length();i++){ int start=i; int end=str.length()-1; while(start<end) { if (str.charAt(start) == str.charAt(end)) { String newstr = str.substring(start, end+1); String substr = newstr.substring(1, newstr.length()-1); if (substr.contains(String.valueOf(newstr.charAt(0)))) { start++; break; } else { result = result.length() > newstr.length() ? result : newstr; break; } } else { end--; } } } System.out.println(result); } }
(五)
public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int L = sc.nextInt(); int Z=sc.nextInt(); //解二元一次方程 x+3y=L 6x+4y=Z int x=(3*Z-4*L)/14; int y=(6*L-Z)/14; System.out.println(x+" "+y); } }