51,679
社区成员
发帖
与我相关
我的任务
分享第一题: 门牌制作

package 打卡;
public class 门牌制作 {
static int count = 0;
public static void main(String[] args) {
// TODO Auto-generated method stub
int n = 2020;
for (int i = 2; i <= n; i++) check(i);
System.out.println(count);
}
static void check(int mm) {
String str = "2";
while (mm != 0) {
int f = mm % 10;
if (str.contains(f + ""))count++;
mm /= 10;
}
}
}
第二题:货物摆放

package 打卡;
import java.util.ArrayList;
public class 货物摆放 {
public static void main(String[] args) {
// TODO Auto-generated method stub
long n = 2021041820210418l,count=0;
ArrayList <Long > list = new ArrayList<Long >();
for(long i =1; i*i<=n;i++) {
//判断是否是n的约数
if(n%i==0) {
list.add(i);
//找到第一个约数后,找第二个约数,并且他们需要不重复
long m =n/i;
if(m!=i)list.add(m);
}
}
//开始遍历判断 是否符合个约数相乘等于n
for( long i : list) {
for(long j :list) {
long cc=n/i/j;
if(cc*i*j==n)count++;
}
}
System.out.println(count);
}
}
第三题:跳跃
……
第四题:重新排序
……