public class main {
final static long MAX = 59084709587505L;
public static void main(String[] args) {
long t = 1;
int[] a = {3,5,7};
TreeSet<Long> s = new TreeSet<>();//可自动排序去重
while (true){
for (int i = 0; i < a.length; i++){
Long tt = a[i] * t;
if (tt <= MAX){
s.add(tt);
}
}
t = s.higher(t);//从TreeSet中选择比t大的最小数
if (t >= MAX) break;
}
System.out.println(s.size());
}
}
蓝桥杯:第几个幸运数(java)
最新推荐文章于 2023-11-24 11:02:40 发布