728x90
반응형
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int a = scanner.nextInt();
int b = scanner.nextInt();
int c = scanner.nextInt();
int d = scanner.nextInt();
int e = scanner.nextInt();
int res = (int) ((Math.pow(a,2)+Math.pow(b,2)+Math.pow(c,2)+Math.pow(d,2)+Math.pow(e,2))%10);
System.out.println(res);
}
}
Math.pow로 a~e를 2번 곱해준 뒤 모두 더해 10을 나눈 나머지를 구한 값을 res에 넣음.
이때 1.0으로 나오기때문에 int로 변환하여 소수점을 제거함.
728x90
반응형
'백준' 카테고리의 다른 글
[JAVA] 백준 2739번 구구단 (0) | 2023.02.23 |
---|---|
[JAVA] 백준 2557번 Hello World (0) | 2023.02.17 |
[JAVA] 백준 2438번 별 찍기 - 1 (0) | 2023.02.17 |
[JAVA] 백준 2420번 사파리월드 (0) | 2023.02.17 |
[JAVA] 백준 1330번 두 수 비교하기 (0) | 2023.02.17 |