반응형
[알고리즘]
나머지
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | import java.util.Scanner; public class java10430 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); int c = scan.nextInt(); if(a<2||b<2||c<2||a>10000||b>10000||c>10000) { a = scan.nextInt(); b = scan.nextInt(); c = scan.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); } } | cs |
A+B - 2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import java.util.Scanner; public class java2558 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); while (a+b>10) { a = scan.nextInt(); b = scan.nextInt(); } System.out.println(a+b); } } | cs |
반응형
'CS > Algorithm' 카테고리의 다른 글
[알고리즘] for문 사용해보기 (0) | 2017.10.20 |
---|---|
[BOJ][JAVA][2839] 설탕옮기기 (0) | 2017.10.20 |
[알고리즘] 연산 (0) | 2017.10.19 |
[알고리즘] A/B (0) | 2017.10.19 |
[알고리즘] A*B (0) | 2017.10.19 |
댓글