洛谷题目联系
P5716(注意特殊情况,平年和闰年的2月份天数)
package 洛谷;
import java.util.Scanner;
public class P5716 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int y,n;
System.out.print("y=");
y = sc.nextInt();
System.out.print("n=");
n = sc.nextInt();
if(y % 4 == 0&&n == 2){
System.out.print(28);
}else if(n ==2){
System.out.println(29);
}
switch (n){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
System.out.print(31);
break;
case 4:
case 6:
case 9:
case 11:
System.out.print(30);
break;
}
}
}
P1412(找对落脚点,此题的体突破点即为x为6/7是产生的问题)
import java.util.Scanner;
public class P1412 {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
long ans = 0, x, n;
x = cin.nextLong();
n = cin.nextLong();
for (int i = 0; i < n; i++) {
if (x != 6 && x != 7) {
ans += 250;
} else if(x ==7){
x = 0;
}
x++;
}
System.out.print(ans);
}
}
P5717
import java.util.Scanner;
public class P5717 {
public static void main(String[] args) {
int a,b,c;
Scanner sc = new Scanner(System.in);
a=sc.nextInt();b = sc.nextInt();c=sc.nextInt();
if(a + b <= c){
System.out.println("Not triangle");
} else if(a == b && b ==c){
System.out.println("Right triangle"+"\n"+"Isosceles triangle"+"\n"+"Equilateral triangle");
} else if ( a*a + b*b == c*c || a*a + c*c ==b*b || b*b +c*c ==a*a ) {
System.out.println("Right triangle");
} else if (a == b || a == c || b == c) {
System.out.println("Obtuse triangle\n" +
"Isosceles triangle");
} else if (a*a + b*b > c*c || a*a + c*c > b*b || b*b +c*c > a*a) {
System.out.println("Acute triangle");
} else if (a*a + b*b < c*c || a*a + c*c < b*b || b*b +c*c < a*a) {
System.out.println("Obtuse triangle");
}
}
}
P5713
import java.util.Scanner;
public class P5713 {
public static void main(String[] args) {
int n;
Scanner sc = new Scanner(System.in);
System.out.println();
n = sc.nextInt();
int x;
x = n * 5;
int y;
y = n * 3 +11;
if(x > y){
System.out.print("Local");
} else if (x < y) {
System.out.print("Luogu");
}else{
System.out.print("都可以");
}
}
}
P5712
import java.util.Scanner;
public class P5712 {
public static void main(String[] args) {
int x;
Scanner sc = new Scanner(System.in);
x = sc.nextInt();
if(x == 0){
System.out.println("Today, i ate 0 apple.");
} else if (x == 1) {
System.out.println("Today, i ate 1 apple.");
}else{
System.out.println("Today,i ate"+"\t"+x+"\t"+"apples.");
}
}
}
P5711(年份能够被4整除的是闰年,其余则为平年。@m0_75278009)
import java.util.Scanner;
public class P5711 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("输入年份n=");
int n = sc.nextInt();
if(n % 4 ==0){
System.out.println(1);
}else{
System.out.println(0);
}
}
}