![[백준 / BOJ] 10430번 나머지 (C++, Python)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FIzdwx%2FbtrLiiV3ZhJ%2FsAHpH7lbArQl3SnXcyESa1%2Fimg.jpg)
[백준 / BOJ] 10430번 나머지 (C++, Python)◎ 자료구조와 알고리즘/백준(BOJ) 문제풀이2022. 9. 4. 18:08
반응형
링크 : https://www.acmicpc.net/problem/10430
10430번: 나머지
첫째 줄에 A, B, C가 순서대로 주어진다. (2 ≤ A, B, C ≤ 10000)
www.acmicpc.net
문제

문제 풀이
문제에 나온 식을 그대로 따라쓰면 된다.
코드 전문
C++
This file contains 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
#include <iostream> | |
#include <vector> | |
void init() { | |
std::ios_base::sync_with_stdio(false); | |
std::cin.tie(nullptr); | |
std::cout.tie(nullptr); | |
} | |
int main() { | |
init(); | |
int A, B, C; | |
std::cin >> A >> B >> C; | |
std::cout << (A + B) % C << "\n"; | |
std::cout << ((A % C) + (B % C)) % C << "\n"; | |
std::cout << (A * B) % C << "\n"; | |
std::cout << ((A % C) * (B % C)) % C << "\n"; | |
return 0; | |
} |
Python
This file contains 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
import sys | |
input = sys.stdin.readline | |
if __name__ == "__main__": | |
A, B, C = map(int, input().split()) | |
print((A + B) % C, ((A % C)+(B % C)) % C, (A * B) % C, ((A % C)*(B % C)) % C, sep="\n") |
소감
반응형
'◎ 자료구조와 알고리즘 > 백준(BOJ) 문제풀이' 카테고리의 다른 글
[백준 / BOJ] 10171번 고양이 (C++, Python) (부제 : 이스케이프 시퀀스) (0) | 2022.09.04 |
---|---|
[백준 / BOJ] 2588번 곱셈 (C++, Python) (0) | 2022.09.04 |
[백준 / BOJ] 3003번 킹, 퀸, 룩, 비숍, 나이트, 폰 (C++, Python) (0) | 2022.09.03 |
[백준 / BOJ] 18108번 1998년생인 내가 태국에서는 2541년생?! (C++, Python) (0) | 2022.09.02 |
[백준 / BOJ] 10926번 ??! (C++, Python) (0) | 2022.09.01 |
@Reo :: 코드 아카이브
자기계발 블로그