Computer Science (CS)/알고리즘

[백준/Java] 10430번 나머지

eune7 2023. 2. 26. 22:00
728x90
반응형

 

 


 

문제

 

 

 

정답 코드

import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
	    Scanner in = new Scanner(System.in);
	    int A = in.nextInt();
            int B = in.nextInt();
            int C = in.nextInt();
        
            System.out.println((A+B)%C);
            System.out.println(((A%C) + (B%C))%C);
            System.out.println((A*B)%C);
            System.out.println(((A%C) * (B%C))%C);
 
	    in.close();
	}
}

이 문제도 사칙연산과 다른게 없어요.

연산식이 조금 복잡해서 괄호를 빼먹는 등 오타가 생길 수 있는데요

문제를 복사 붙여넣기 한 후에 X를 *로만 바꿔주시면 

좀 더 쉽게 문제를 풀 수 있습니다!

728x90
반응형