쉽고 깔끔하게
[백준 알고리즘/python3] 10430번 나머지 문제풀이 본문
728x90
반응형

문제
10430번: 나머지
첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C ≤ 10000)
www.acmicpc.net
(A+B)% C는 ((A% C) + (B% C))% C와 같을까?
(A✕B)% C는 ((A% C) ✕ (B% C))% C와 같을까?
세 수 A, B, C가 주어졌을 때, 위의 네 가지 값을 구하는 프로그램을 작성하시오.
입력
첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C, ≤ 10000)
출력
첫째 줄에 (A+B)%C, 둘째 줄에 ((A% C) + (B% C))% C, 셋째 줄에 (A✕B)% C, 넷째 줄에 ((A% C)✕(B% C))% C를 출력한다.
예제 입력 | 예제 출력 |
5 8 4 | 1 1 0 0 |
<정답>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A, B, C = input().split() | |
a = int(A) | |
b = int(B) | |
c = int(C) | |
print((a+b)%c) | |
print(((a%c)+(b%c))%c) | |
print((a*b)%c) | |
print(((a%c)*(b%c))%c) |
728x90
반응형
'Algorithm > BAEKJOON' 카테고리의 다른 글
[백준 알고리즘/python3] 1330번 두 수 비교하기 문제풀이 (0) | 2020.12.28 |
---|---|
[백준 알고리즘/python3] 2588번 곱셈 문제풀이 (0) | 2020.12.26 |
[백준 알고리즘/python3] 10869번 사칙연산 문제풀이 (0) | 2020.12.26 |
[백준 알고리즘/python3] 1008번 A/B 문제풀이 (0) | 2020.12.26 |
[백준 알고리즘/python3] 10998번 A✕B 문제풀이 (0) | 2020.12.26 |