6/8/11/13 WA了
查看原帖
6/8/11/13 WA了
45128
Asiimov楼主2020/6/2 21:14

第六个真的不知道咋整呀,说是直接用cout输出,但是我寻思着这样应该也可以呀:

import java.util.*;

public class Main {
    private static Main instance;
    private Scanner scanner;
    protected double pi = 3.141593;

    private int questionNum;

    public Main() {
        scanner = new Scanner(System.in);
        questionNum = scanner.nextInt();
        switch(questionNum) {
            case 1:
                questionOne();
                break;
            case 2:
                questionTwo();
                break;
            case 3:
                questionThree();
                break;
            case 4:
                questionFour();
                break;
            case 5:
                questionFive();
                break;
            case 6:
                questionSix();
                break;
            case 7:
                questionSeven();
                break;
            case 8:
                questionEight();
                break;
            case 9:
                questionNine();
                break;
            case 10:
                questionTen();
                break;
            case 11:
                questionEleven();
                break;
            case 12:
                questionTwelve();
                break;
            case 13:
                questionThirteen();
                break;
            case 14:
                questionFourteen();
                break;
            default:
                System.out.printf("WTF???\n");
                break;
        }
    }

    public static void main(String[] args) {
        instance = new Main();
    }

    private void questionOne() {
        System.out.printf("I love Luogu!\n");
        return;
    }

    private void questionTwo() {
        int appleNum = 10, littleA = 2, uim = 4, eightBraveTails = 0;
        appleNum -= littleA;
        appleNum -= uim;
        eightBraveTails = appleNum;
        appleNum = 0;
        int ans1 = littleA + uim, ans2 = eightBraveTails;
        System.out.printf("%d %d\n", ans1, ans2);
        System.out.flush();
        return;
    }

    private void questionThree() {
        int appleNum = 14, studentNum = 4, applePerStudent = 0, fridgeAppleNum = 0;
        applePerStudent = appleNum / studentNum;
        appleNum = appleNum % studentNum;
        fridgeAppleNum = appleNum;
        appleNum = 0;
        int ans1 = applePerStudent, ans2 = studentNum * applePerStudent, ans3 = fridgeAppleNum;
        System.out.printf("%d\n%d\n%d\n", ans1, ans2, ans3);
        System.out.flush();
        return;
    }

    private void questionFour() {
        double cokeVol = 500.0, cokeVolPerStudent = 0;
        int studentNum = 3;
        cokeVolPerStudent = cokeVol / Double.valueOf(studentNum);
        System.out.printf("%.3f\n", cokeVolPerStudent);
        System.out.flush();
        return;
    }

    private void questionFive() {
        int aTrainLength = 260, aTrainSpeed = 12, bTrainLength = 220, bTrainSpeed = 20;
        int trainTotalLength = aTrainLength + bTrainLength;
        int trainRelativeSpeed = aTrainSpeed + bTrainSpeed;
        int time = trainTotalLength / trainRelativeSpeed;
        System.out.printf("%d\n", time);
        System.out.flush();
        return;
    }

    private void questionSix() {
        int length = 6, width = 9;
        double ans = Math.sqrt(6^2 + 9^2);
        System.out.printf("%f\n", ans);
        System.out.flush();
        return;
    }

    private void questionSeven() {
        int balance = 100;
        balance += 10;
        System.out.printf("%d\n", balance);
        balance -= 20;
        System.out.printf("%d\n", balance);
        balance -= balance;
        System.out.printf("%d\n", balance);
        System.out.flush();
        return;
    }

    private void questionEight() {
        double radius = 5, perimeter, area, volume;
        perimeter = 2 * radius * this.pi;
        area = this.pi * (((int) radius)^2);
        volume = Double.valueOf(4/3) * this.pi * ((((int) radius)^3));
        System.out.printf("%f\n%f\n%f\n", perimeter, area, volume);
        System.out.flush();
        return;
    }

    private void questionNine() {
        int peach = 1;
        for (int i = 0; i < 3; i ++) {
            peach += 1;
            peach = peach * 2;
        }
        System.out.printf("%d\n", peach);
        System.out.flush();
        return;
    }

    private void questionTen() {
        System.out.printf("9\n");
        System.out.flush();
        return;
    }

    private void questionEleven() {
        System.out.printf("%f\n", 1.0*100/3);
        System.out.flush();
        return;
    }

    private void questionTwelve() {
        System.out.printf("13\nR");
        System.out.flush();
        return;
    }

    private void questionThirteen() {
        System.out.printf("%f\n", Math.pow(Double.valueOf(4/3) * this.pi * (4^3 + 10^3), Double.valueOf(1/3)));
        System.out.flush();
        return;
    }

    private void questionFourteen() {
        System.out.printf("50\n");
        System.out.flush();
        return;
    }
}
2020/6/2 21:14
加载中...