写一个辅助函数f来挨个判定即可,记得m和n都要包含,是闭区间

import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int m = sc.nextInt(), n = sc.nextInt();
            int r = 0;
            for(int i = m; i <= n; ++i){
                if(f(i)){
                    r++;
                    System.out.printf("%d ", i);
                }
            }
            if(r == 0){
                System.out.println("no");
                continue;
            }
            System.out.println();
        }
    }
    static boolean f(int n){
        int r = 0, t = n;
        while(t != 0){
            int a = t%10;
            r += (int)Math.pow(a, 3);
            t /= 10;
        }
        if(r == n) return true;
        return false;
    }
}