본문 바로가기

Algorithm_BOJ(백준)/수학(Math)

[백준 10430 c++ OO] 나머지

728x90
반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
/*
[백준 10430 c++ OO] 나머지
문제:주어진 식을 계산
접근: 
시간복잡도:
풀이:
*/
int a, b, c;
 
int main() {
    ios::sync_with_stdio(false); // 계산시간 단축 // cin,scanf 같이 쓰면 오류
    cin.tie(nullptr); cout.tie(nullptr);// 입출력 시간 단축 // 이것을 쓰면 scanf,printf섞어 쓰면 안됨
 
    cin >> a >> b >> c;
    cout << (a + b) % c << '\n';
    cout << ((a%c)+(b%c))%c << '\n';
    cout << (a*b)%c << '\n';
    cout << ((a%c)*(b%c))%c << '\n';
    return 0;
}
 
cs
반응형

'Algorithm_BOJ(백준) > 수학(Math)' 카테고리의 다른 글

[백준 10610 c++ V] 30  (0) 2023.01.12
[백준 1735 c++ O] 분수 합  (0) 2023.01.12
[백준 5543 c++ O] 상근날드  (0) 2021.08.30
[백준 2587 c++ O] 대표값2  (0) 2021.08.30
[백준 2592 c++ O] 대표값  (0) 2021.08.30