Java洛谷刷题(入门1)

P1001 A+B Problem

import java.util.*;

public class Main {
public static void main(String []args){
    Scanner x=new Scanner(System.in);
    int a=x.nextInt();
    int b=x.nextInt();
    System.out.println(a+b);}
}

P1000 超级玛丽游戏

import java.util.*;

public class Main {
public static void main(String []args){
  System.out.println(
          "                ********\n" +
                  "               ************\n" +
                  "               ####....#.\n" +
                  "             #..###.....##....\n" +
                  "             ###.......######              ###            ###\n" +
                  "                ...........               #...#          #...#\n" +
                  "               ##*#######                 #.#.#          #.#.#\n" +
                  "            ####*******######             #.#.#          #.#.#\n" +
                  "           ...#***.****.*###....          #...#          #...#\n" +
                  "           ....**********##.....           ###            ###\n" +
                  "           ....****    *****....\n" +
                  "             ####        ####\n" +
                  "           ######        ######\n" +
                  "##############################################################\n" +
                  "#...#......#.##...#......#.##...#......#.##------------------#\n" +
                  "###########################################------------------#\n" +
                  "#..#....#....##..#....#....##..#....#....#####################\n" +
                  "##########################################    #----------#\n" +
                  "#.....#......##.....#......##.....#......#    #----------#\n" +
                  "##########################################    #----------#\n" +
                  "#.#..#....#..##.#..#....#..##.#..#....#..#    #----------#\n" +
                  "##########################################    ############"
  );
}}

P5703 【深基2.例5】苹果采购

import java.util.*;

public class Main {
public static void main(String []args){
Scanner x = new Scanner(System.in);
int a=x.nextInt();
int b=x.nextInt();
System.out.println(a*b);
    }
}

P5704 【深基2.例6】字母转换

import java.util.*;

public class Main {
public static void main(String []args){
Scanner x = new Scanner(System.in);
String a=x.nextLine();
System.out.println(a.toUpperCase());

    }
}

P5705 【深基2.例7】数字反转

import java.util.*;

public class Main {
public static void main(String []args){
Scanner x = new Scanner(System.in);
String a=x.nextLine();
for (int i=a.length()-1;i>=0;i--){
    System.out.print(a.charAt(i));
}

    }
}

P5706 【深基2.例8】再分肥宅水

import java.util.*;

public class Main {
public static void main(String []args){
Scanner x = new Scanner(System.in);
double a = x.nextDouble();
int n = x.nextInt();
double b=a/n;
System.out.printf("%.3f\n",b);
System.out.println(2*n);

    }
}

P1425 小鱼的游泳时间

import java.util.*;

public class Main {
public static void main(String []args){
    int a,b,c,d;
    Scanner x =new Scanner(System.in);
    a=x.nextInt();
    b=x.nextInt();
    c=x.nextInt();
    d=x.nextInt();
    int e=c-a,f=d-b;
    if(f<0){
        e--;
        f+=60;
    }
    System.out.print(e+" "+f);
}
}

【深基1-2】小学数学 N 合一(略

P5708 【深基2.习2】三角形面积

import java.util.*;
import java.text.*;
import java.math.*;

public class Main {
    public static void main(String []args){
        double a,b,c;
        Scanner x=new Scanner(System.in);
        a=x.nextDouble();
        b=x.nextDouble();
        c=x.nextDouble();
        double s=(a+b+c)/2;
        double z=s*(s-a)*(s-b)*(s-c);
        double n=Math.sqrt(z);

        DecimalFormat df=new DecimalFormat("0.0");
        df.setRoundingMode(RoundingMode.HALF_UP);
        System.out.println(df.format(n));
    }
}

P1421 小玉买文具

import java.util.*;

public class Main {
    public static void main(String []args){
 int a,b,c;
 Scanner x=new Scanner(System.in);
 a=x.nextInt();
 b=x.nextInt();
 c=(a*10+b)/19;
         System.out.println(c);
    }
}

P5709 【深基2.习6】Apples Prologue / 苹果和虫子

import java.util.*;
import java.text.*;
import java.math.*;

public class Main {
    public static void main(String []args){
int m,t,s;
Scanner x=new Scanner(System.in);
m=x.nextInt();
t=x.nextInt();
s=x.nextInt();

if(t==0){
    System.out.println(0);
}else{
    double a=(double)s/t;
    int b=m-(int)Math.ceil(a);
    if(b>=0){
        System.out.println(b);
    }else {
        System.out.println(0);
    }
}

    }
}

P2181 对角线

import java.util.*;
import java.math.*;


public class Main {
    public static void main(String []args){
        BigInteger  m;
Scanner x=new Scanner(System.in);
m=x.nextBigInteger();
        BigInteger ans = m.multiply(m.subtract(BigInteger.valueOf(1)))
                .multiply(m.subtract(BigInteger.valueOf(2)))
                .multiply(m.subtract(BigInteger.valueOf(3)))
                .divide(BigInteger.valueOf(24));
System.out.println(ans);

    }
}

P5707 【深基2.例12】上学迟到

import java.util.*;
import java.text.*;



public class Main {
    public static void main(String []args) {
        int s, v;
        Scanner x = new Scanner(System.in);
        s = x.nextInt();
        v=x.nextInt();
         Calendar date = Calendar.getInstance();
         date.set(0000, Calendar.MAY, 5, 8, 0, 0);
         date.add(Calendar.MINUTE, -10);
           date.add(Calendar.MINUTE, s % v == 0 ? -(s / v) : -(s / v) - 1);
          SimpleDateFormat format = new SimpleDateFormat("HH:mm");
                 System.out.println(format.format(date.getTime()));
        }
}

P3954 [NOIP2017 普及组] 成绩

import java.util.*;

public class Main {
    public static void main(String []args) {
 int a,b,c;
 Scanner x=new Scanner(System.in);
 a=x.nextInt();
 b=x.nextInt();
 c=x.nextInt();
        System.out.format("%.0f",a*0.2+b*0.3+c*0.5);
        }
}
  • 6
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mingshengda

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值