Updated:

1. 문제 링크

https://www.acmicpc.net/problem/10430

2. 사용 알고리즘

구현

3. 풀이

문제에서 주어진 네 가지 계산식 결과 출력

4. 소스 코드

4-1. C++

https://github.com/dev-aiden/problem-solving/blob/main/boj/10430.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>

using namespace std;

int main(void) {
    ios_base::sync_with_stdio(false);
    int a, b, c; 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;
}

4-2. JAVA

https://github.com/dev-aiden/problem-solving/blob/main/boj/10430.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        int c = Integer.parseInt(st.nextToken());
        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);
    }
}

Updated:

Leave a comment