1.P2433 【深基1-2】小学数学 N 合一
![](https://i-blog.csdnimg.cn/blog_migrate/b9ba561b82015cf59faac0914dbca314.png)
![](https://i-blog.csdnimg.cn/blog_migrate/6ad17d8c02997fd787ec9757732a8ec8.png)
![](https://i-blog.csdnimg.cn/blog_migrate/5a1617e9b4355b0dab36d26bbbbdce62.png)
![](https://i-blog.csdnimg.cn/blog_migrate/56c88e2e971bb5638107316d3e9cf368.png)
![](https://i-blog.csdnimg.cn/blog_migrate/52c9847acce1d2b9ccc8e1916ff3772e.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
double pi = 3.141593;
Scanner sc = new Scanner(System.in);
switch (sc.nextInt()) {
case 1:
System.out.println("I love Luogu!");
break;
case 2:
System.out.print("6 4");
break;
case 3:
System.out.println(3);
System.out.println(12);
System.out.println(2);
break;
case 4:
double a = (double)500/3;
System.out.printf("%.3f", a);
break;
case 5:
System.out.println((220+260)/(20+12));
break;
case 6:
double b = Math.sqrt(6*6+9*9);
System.out.printf("%.4f",b);
break;
case 7:
System.out.println(110);
System.out.println(90);
System.out.println(0);
break;
case 8:
double r=5;
System.out.printf("%.4f\n",2*pi*r);
System.out.printf("%.4f\n", pi*r*r);
System.out.printf("%.3f\n", 4.0/3.0*pi*r*r*r);
break;
case 9:
System.out.println(22);
break;
case 10:
System.out.println(9);
break;
case 11:
double c = 1.0*100/3;
System.out.printf("%.4f", c);
break;
case 12:
System.out.println((int)('M'-'A')+1);
System.out.println((char)('A'+18-1));
break;
case 13:
int r1=5,r2=10;
double v1 =4*pi*r1*r1*r1/3+4*pi*r2*r2*r2/3;
double v2 =Math.pow(v1, 1.0*1/3);
System.out.println((int)v2);
break;
case 14:
System.out.println(50);
break;
}
}
}
2.P5709 【深基2.习6】Apples Prologue / 苹果和虫子
![](https://i-blog.csdnimg.cn/blog_migrate/9a45f8b4c2ceccd3e46bbed037a396c7.png)
![](https://i-blog.csdnimg.cn/blog_migrate/298c077a2c2c8be81e3db6cdfa3ea49f.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
int t = sc.nextInt();
int s = sc.nextInt();
if (t == 0) {
System.out.println(0);
}else {
int eat = s/t + (s%t != 0? 1:0);
System.out.println((m-eat) >= 0? (m-eat):0);
}
}
}
3.P5710 【深基3.例2】数的性质
![](https://i-blog.csdnimg.cn/blog_migrate/77a0d04598887b9f2769e809487ee875.png)
![](https://i-blog.csdnimg.cn/blog_migrate/930b9b4d02a56631f8bf56c008353f71.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int r = sc.nextInt();
int sum =0;
if(r%2 == 0){
sum++;
}
if(r>4 && r<=12){
sum++;
}
if(sum==2){
System.out.println("1 1 0 0");
}else if(sum==1){
System.out.println("0 1 1 0");
}else{
System.out.println("0 0 0 1");
}
}
}
4.P5711 【深基3.例3】闰年判断
![](https://i-blog.csdnimg.cn/blog_migrate/421d10559159cb8056ec01d4322601a2.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a4534fc1e5a9333f59d1a1fe0423758a.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
if ((a%4 == 0 && a%100 !=0)|| a% 400 == 0) {
System.out.println("1");
}else {
System.out.println("0");
}
}
}
5.P5712 【深基3.例4】Apples
![](https://i-blog.csdnimg.cn/blog_migrate/a8676f0bdb9a8af5e81eb798ca708829.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1779fd5d3395de45f120949e04108315.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
if (x <= 1) {
System.out.printf("Today, I ate %d apple.",x);
}else {
System.out.printf("Today, I ate %d apples.",x);
}
}
}
6.P5713 【深基3.例5】洛谷团队系统
![](https://i-blog.csdnimg.cn/blog_migrate/4c34516a3b445b8a1f724bd4d6162039.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e8f6f37ca678fab8d1bcf3f34570fde3.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = 5*n;
int b = 11+3*n;
if(a>b) {
System.out.println("Luogu");
}else {
System.out.println("Local");
}
}
}
7.P5714 【深基3.例7】肥胖问题
![](https://i-blog.csdnimg.cn/blog_migrate/7540c1e7642c9c06f413073801b348cf.png)
![](https://i-blog.csdnimg.cn/blog_migrate/3327a4f853a24c923c5070848bc3b927.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double m = sc.nextDouble();
double h = sc.nextDouble();
double BMI= m/(h*h);
if(BMI<18.5) {
System.out.println("Underweight");
} else if(18.5<=BMI && BMI<24) {
System.out.println("Normal");
} else {
System.out.printf("%.4f\n",BMI);
System.out.println("Overweight");
}
}
}
8.P5715 【深基3.例8】三位数排序
![](https://i-blog.csdnimg.cn/blog_migrate/fcbe2a06e73e7de3cc0eb2720cc05c64.png)
![](https://i-blog.csdnimg.cn/blog_migrate/e6894d8d03374c80c16046654df49366.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] num = new int[3];
for(int i=0;i<3;i++)
num[i] = sc.nextInt();
for(int i=0;i<num.length-1;i++) {
for(int j=0;j<=num.length-1-j;j++) {
if(num[j] > num[j+1]) {
int temp = num[j];
num[j] = num[j+1];
num[j+1] = temp;
}
}
}
for(int i=0;i<3;i++)
System.out.print(num[i]+" ");
}
}
9.P5716 【深基3.例9】月份天数
![](https://i-blog.csdnimg.cn/blog_migrate/0fb582fb5d193e91a7b0fad96b1ec94a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/fd9f4ba109355b5244d33a9fd44eb45e.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int year = sc.nextInt();
int month = sc.nextInt();
switch (month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
System.out.print("31");
return;
case 4:
case 6:
case 9:
case 11:
System.out.print("30");
return;
}
if (judge(year)==true){
System.out.print("29");
}
else {
System.out.print("28");
}
}
public static boolean judge(int n){
if(((n%4==0)&&n%100!=0)|| n%400==0) {
return true;
}
else {
return false;
}
}
}
10.P1085 [NOIP2004 普及组] 不高兴的津津
![](https://i-blog.csdnimg.cn/blog_migrate/ea6e6b49df9fa6f2377d83fcd6a22878.png)
![](https://i-blog.csdnimg.cn/blog_migrate/068fd6f81ef0c9ff8478d025cda26714.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum, max = 0,day = 0;
for(int i=0;i<7;i++) {
int schoolIn = sc.nextInt();
int schoolOut = sc.nextInt();
sum = schoolIn + schoolOut;
if(sum > max) {
max = sum;
day = i + 1;
}
}
if(max > 8) {
System.out.println(day);
}else {
System.out.println(0);
}
}
}
11.P1909 [NOIP2016 普及组] 买铅笔
![](https://i-blog.csdnimg.cn/blog_migrate/9fc07a288bf0d8ecd949395a0283bb39.png)
![](https://i-blog.csdnimg.cn/blog_migrate/dadf20e596a019f800f8419b09fdf1c3.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int a;
int b1,b2;
int c1,c2;
int d1,d2;
Scanner sc = new Scanner(System.in);
a=sc.nextInt();
b1=sc.nextInt();b2=sc.nextInt();
c1=sc.nextInt();c2=sc.nextInt();
d1=sc.nextInt();d2=sc.nextInt();
int m1,m2,m3;
if(a%b1!=0){
m1 = (a/b1+1)*b2;}
else {
m1 = (a/b1)*b2;
}
if(a%c1!=0){
m2 = (a/c1+1)*c2;
}else {
m2 = a/c1*c2;
}
if(a%d1!=0){
m3 = (a/d1+1)*d2;}
else {
m3 = (a/d1*d2);
}
if(m1<=m2&&m1<=m3) {
System.out.print(m1);
}else if(m2<=m1&&m2<=m3) {
System.out.print(m2);
}else if(m3<=m1&&m3<=m2) {
System.out.print(m3);
}
}
}
12.P5717 【深基3.习8】三角形分类
![](https://i-blog.csdnimg.cn/blog_migrate/ea0061b4eab567d3c393b292d859d83a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/627c6d71b775460aec1c6c695c3a2eb1.png)
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
int[] array = {a,b,c};
Arrays.sort(array);
a = array[0];
b = array[1];
c = array[2];
if (!((a + b > c) && ((c - a) < b) && ((b - a) < c) && ((c - b) < a))) {
System.out.println("Not triangle");
System.exit(0);
}
if ((a * a + b * b) > (c * c)) {
System.out.println("Acute triangle");
}
if ((a * a + b * b) == (c * c)) {
System.out.println("Right triangle");
}
if ((a * a + b * b) < (c * c)) {
System.out.println("Obtuse triangle");
}
if (((a == b) || (b == c) ||(a == c))) {
System.out.println("Isosceles triangle");
}
if ((a == b) &&(b == c)) {
System.out.println("Equilateral triangle");
}
}
}
13.P1422 小玉家的电费
![](https://i-blog.csdnimg.cn/blog_migrate/2675bc15cbcd70363e49f1b8352894fb.png)
![](https://i-blog.csdnimg.cn/blog_migrate/a04c2f0b4f703dcb577f59099da9ffb5.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int e=sc.nextInt();
double money;
if(e<=150) {
money=e*0.4463;
}else if(e>150 && e<=400) {
money=(e-150)*0.4663+150*0.4463;
}else {
money=(e-400)*0.5663+250*0.4663+150*0.4463;
}
System.out.printf("%.1f",money);
}
}
14.P1424 小鱼的航程(改进版)
![](https://i-blog.csdnimg.cn/blog_migrate/3161ac59167b5ac3f7e3cd4e018901f0.png)
![](https://i-blog.csdnimg.cn/blog_migrate/81da2ccde3523a07698822dbe8d8f5c1.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int week = sc.nextInt();
int day = sc.nextInt();
int sum = 0;
for (int i=0;i<day;i++) {
if(week!=6 && week!=7) {
sum+=250;
}
if(week==7) {
week=1;
}else {
week++;
}
}
System.out.println(sum);
}
}
15.P1888 三角函数
![](https://i-blog.csdnimg.cn/blog_migrate/929037a823341867eafc75f04da8b7d9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/4d9a6a8bf50b643e5ef92f65761678fa.png)
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
BigInteger[] arr = new BigInteger[3];
for(int i=0;i<3;i++) {
arr[i] = sc.nextBigInteger();
}
Arrays.sort(arr);
System.out.printf("%d/%d",arr[0].divide(arr[0].gcd(arr[2])),arr[2].divide(arr[0].gcd(arr[2])));
}
}
16.P1046 [NOIP2005 普及组] 陶陶摘苹果
![](https://i-blog.csdnimg.cn/blog_migrate/5a13c34a00ccf99404cefba1822e2087.png)
![](https://i-blog.csdnimg.cn/blog_migrate/37b27ac72c0baf70f91640dba4dd3f34.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int[] AppleHeights = new int[10];
Scanner sc = new Scanner(System.in);
for (int i = 0; i < 10; i++) {
int AppleHeight = sc.nextInt();
AppleHeights[i] = AppleHeight;
}
int PeopleHeight = sc.nextInt() + 30;
int j = 0;
for (int i = 0; i < 10; i++) {
if (AppleHeights[i] <= PeopleHeight) {
j++;
}
}
System.out.println(j);
}
}
17.P4414 [COCI2006-2007#2] ABC
![](https://i-blog.csdnimg.cn/blog_migrate/97ed1a87df2eefcc8c9565399032e98e.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1a3c096e2238e7c1bcaec3fb869e2670.png)
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
String s = sc.next();
int arr[] = {a,b,c};
Arrays.sort(arr);
if (s.equals("ABC")) {
System.out.print(arr[0]+" "+arr[1]+" "+arr[2]);
}
else if(s.equals("ACB")) {
System.out.print(arr[0]+" "+arr[2]+" "+arr[1]);
}
else if(s.equals("BAC")) {
System.out.print(arr[1]+" "+arr[0]+" "+arr[2]);
}
else if(s.equals("BCA")) {
System.out.print(arr[1]+" "+arr[2]+" "+arr[0]);
}
else if(s.equals("CAB")) {
System.out.print(arr[2]+" "+arr[0]+" "+arr[1]);
}
else if(s.equals("CBA")) {
System.out.print(arr[2]+" "+arr[1]+" "+arr[0]);
}
}
}
18.P1055 [NOIP2008 普及组] ISBN 号码
![](https://i-blog.csdnimg.cn/blog_migrate/c489134c9d07e6c293c3efe9514e1774.png)
![](https://i-blog.csdnimg.cn/blog_migrate/d3877f4a157b47c0d270d756d6219d6f.png)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
String rawCode = new Scanner(System.in).next();
String code = rawCode.replace("-", "");
int sum = 0, expect = code.charAt(9) - '0';
expect = code.charAt(9) == 'X' ? 10 : expect;
for (int i = 0; i < 9; i++){
sum += (code.charAt(i) - '0') * (i + 1);
sum %= 11;
}
if (expect == sum) {
System.out.println("Right");
}else {
System.out.println(rawCode.substring(0, 12) + (sum == 10 ? "X" : sum));
}
}
}