[Java] Baekjun #2588 - Multiplication
We have summarized the solution that separates the multiplication process into division and remainder operations in Java.
한국어 원문은 여기에서 볼 수 있습니다.
[Java] Baekjun #2588 - Multiplication
Solution
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.util.Scanner;
public class Main{
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
int a = input.nextInt();
int b = input.nextInt();
int c = a * (b%10);
int d = a * ((b%100)/10);
int e = a * (b/100);
int f = a * b;
System.out.printf("%d\n%d\n%d\n%d", c, d, e, f);
}
}
In Java, the / operator was calculated using the fact that it returns only the quotient.