奇数倍数
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改
public class Main {
public static void main(String[] args) {
int num = 0;
for(int i= 1;;i++) {
num = i*2019;
if(ji(num)) {
System.out.println(num);
break;
}
}
}
public static boolean ji(int num) {
boolean re = true;
while(num > 0) {
int x = num%10;
if(x%2 == 0) {
re = false;
}
num = num/10;
}
return re;
}
}
求值
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改
public class Main {
public static void main(String[] args) {
for (int i = 45360;;i++) {//暴力算法但对于填空就无所谓了
int n = 0;
boolean flag = false;
for (int j = 1; j <= i; j++) {
if (i % j == 0) {
n++;
if (n == 100) {
System.out.println(i);
flag = true;
break;
}
}
}
if (flag) {
break;
}
}
}
}
求和
import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
//在此输入您的代码...
int n = sc.nextInt();
long [] arr = new long[n];
long sum = 0l;
for(int i = 0; i<arr.length;i++){
arr[i] = sc.nextInt();
sum +=arr[i];
}
long re =0l;
for(int i = 0; i<arr.length-1;i++){
sum -= arr[i];
re += sum*arr[i];
}
System.out.println(re);
sc.close();
}
}
数位排序
package textDemo;
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StreamTokenizer st = new StreamTokenizer(br);
static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//在此输入您的代码...
//数位排序
int n = scan.nextInt();
int m = scan.nextInt();
int [] ints = new int [n];
int index = 0;
lab:
//这里可以加上这一段,差不多就是一个事件,然后break只能跳出内层循环,加上这个就可调到这里
for(int i = 1;i<n;i++){
for(int k = 1;k <= n;k++){
//之前一直都没有办法哦通过测试就是因为k<=n被我写成了i,这样肯定是没有办法的
if (count(k) == i) ints[index++]=k;
if (index>=n) break lab;
}
}
System.out.println(ints[m-1]);
scan.close();
}
public static int count(int num){
int he =0;
int x;
while(num!=0){
x = num%10;
he +=x;
num /=10;
}
return he;
}
}