CCF 202012-1 Final Forecast Safety Index (Water Question)

Portal

Idea: Ah, this, isn't it just a water problem, but java rookie has to search even input and output ┭┮﹏┭┮.

Code:

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int ans = 0, x, y;
        for(int i = 0; i < n; i ++){
            x = input.nextInt();
            y = input.nextInt();
            ans += x*y;
        }
        System.out.println(Math.max(ans, 0));
    }
}

 

Guess you like

Origin blog.csdn.net/Satur9/article/details/114955526