Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

TitanYang's Programming

[JAVA 기본 알고리즘] 백준 알고리즘 2291번 / 사나운개 본문

JAVA

[JAVA 기본 알고리즘] 백준 알고리즘 2291번 / 사나운개

타이탄양 2017. 8. 3. 14:50



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
public class dog {
 
 
    public static void main(String[] args) {
        // TODO Auto-generated method stub
            Scanner sc = new Scanner(System.in);
            int ax = sc.nextInt();
            int ay = sc.nextInt();
            int bx = sc.nextInt();
            int by = sc.nextInt();
            int p[] = new int[3];
            int dogcnt[] = new int[3];
            for(int i=0; i<3 ;i++) {
                p[i] = sc.nextInt();
                dogcnt[i]=0;
            }
            for(int i=0; i<3;i++) {
                if(p[i]%(ax+ay)>=1 && p[i]%(ax+ay)<=ax) {
                    dogcnt[i]++;
                }
                if(p[i]%(bx+by)>=1 && p[i]%(bx+by)<=bx) {
                    dogcnt[i]++;
                }
                System.out.println(dogcnt[i]);
            }
    }
}
 
cs