2021.09.15 작성
문제에서 주어진 식들에 대하여 출력만 하면 되는 간단한 문제이다.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
/* 일반 입출력 */
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int 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);
}
}
import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
/* 빠른 입출력 */
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(bf.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int c = Integer.parseInt(st.nextToken());
bw.write(String.valueOf((a + b) % c) + "\n");
bw.write(String.valueOf(((a % c) + (b % c)) % c) + "\n");
bw.write(String.valueOf((a * b) % c) + "\n");
bw.write(String.valueOf(((a % c) * (b % c)) % c));
bw.flush();
bw.close();
}
}
따로 코드들에 대해서 설명 할 내용은 없다.
제출 번호 33338420번 - 일반 입력
제출 번호 33338430번 - 빠른 입력