정리하고기록하자
백준 (JAVA) - 나머지 (10430) 본문
반응형
백준 - 알고리즘 나머지 (10430) 문제
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a,b,c;
a = sc.nextInt();
b = sc.nextInt();
c = sc.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 );
}
}
변수 a,b,c 선언 후
문제에 출력 순서대로 출력 했다.
출력 : 첫째 줄에 (A+B)%C, 둘째 줄에 ((A%C) + (B%C))%C, 셋째 줄에 (A×B)%C, 넷째 줄에 ((A%C) × (B%C))%C를 출력한다.
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 );
반응형
'백준 - 알고리즘' 카테고리의 다른 글
백준 (JAVA) - 두 수 비교하기 (1330) (0) | 2021.10.04 |
---|---|
백준 (JAVA) - 곱셈 (2588) (0) | 2021.08.31 |
백준 (JAVA) - 사칙연산 (10869) (0) | 2021.08.29 |
백준 (JAVA) - A/B (1008) (0) | 2021.08.29 |
백준(JAVA) - AxB (10998) (0) | 2021.08.29 |