Skip to content

Instantly share code, notes, and snippets.

@BrendenHJH
Created May 17, 2018 08:23
Show Gist options
  • Save BrendenHJH/7d950fb426b7ac27ae4fc0ceee8b0d02 to your computer and use it in GitHub Desktop.
Save BrendenHJH/7d950fb426b7ac27ae4fc0ceee8b0d02 to your computer and use it in GitHub Desktop.
백준 10984 내 학점을 구해줘
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
while(n-- > 0) {
int m = sc.nextInt();
int gradeSum = 0;
float scoreSum = 0;
for(int i = 0; i < m; i++) {
int a = sc.nextInt();
double b = sc.nextDouble();
gradeSum += a;
scoreSum += a * b;
}
System.out.println(gradeSum + " " + Math.round(scoreSum*10/gradeSum)/10.0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment