4.1w+
社区成员
数的分解
public class Main {
public static void main(String[] args) {
int res = 0;
for(int i = 1; i < 1009; i++){
if(!judge(i)){
continue;
}
for(int j = i + 1; j < 2019; j++){
int k = 2019 - i - j;
if(!judge(k) || !judge(j)){
continue;
}
if(i < j && j < k){
res++;
}
}
}
System.out.println(res);
}
static boolean judge(int i){
int num = i;
while(num > 0){
int red = num % 10;
if(red == 2 || red == 4){
return false;
}
num /= 10;
}
return true;
}
}
猜生日
public class Main {
public static void main(String[] args) {
int year = 2012;
int month = 3;
int day = 12;
for(int i = 1900; i < 2012; i++){
StringBuilder builder = new StringBuilder(String.valueOf(i));
builder.append("06");
for(int j = 1; j <= 30; j++){
if(j < 10){
builder.append(0);
builder.append(j);
}else{
builder.append(j);
}
Long num = Long.valueOf(builder.toString());
if(num % year == 0 && num % month == 0 && num % day == 0){
System.out.println(builder.toString());
return;
}
builder.deleteCharAt(builder.length() - 1);
builder.deleteCharAt(builder.length() - 1);
}
}
}
}
成绩统计
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//在此输入您的代码...
int num = scan.nextInt();
double pass = 0;
double excellent = 0;
for(int i = 0; i < num; i++){
int score = scan.nextInt();
if(score >= 85){
excellent++;
}
if(score >= 60){
pass++;
}
}
System.out.println(Math.round(pass * 100 / num) + "%");
System.out.println(Math.round(excellent * 100 / num) + "%");
scan.close();
}
}