๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜

[๋ฐฑ์ค€ ์•Œ๊ณ ๋ฆฌ์ฆ˜] 10430๋ฒˆ - ๋‚˜๋จธ์ง€

by ์ฝ”๋”ฉํ•˜๋Š” ๋ถ•์–ด 2021. 1. 30.
๋ฐ˜์‘ํ˜•

1. ์ž…์ถœ๋ ฅ๊ณผ ์‚ฌ์น™์—ฐ์‚ฐ - ๋‚˜๋จธ์ง€

 

 

๋ฌธ์ œ) (A+B)%C๋Š” ((A%C) + (B%C))%C ์™€ ๊ฐ™์„๊นŒ?

(A×B)%C๋Š” ((A%C) × (B%C))%C ์™€ ๊ฐ™์„๊นŒ?

์„ธ ์ˆ˜ A, B, C๊ฐ€ ์ฃผ์–ด์กŒ์„ ๋•Œ, ์œ„์˜ ๋„ค ๊ฐ€์ง€ ๊ฐ’์„ ๊ตฌํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

์ž…๋ ฅ ์ถœ๋ ฅ
5  8  4 1
1
0
0

 

import java.util.Scanner;

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);
	}
}

%๋ฅผ ์ดํ•ดํ•˜๊ณ ์žˆ์–ด์•ผํ•จ

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€