๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ์žฅ์›์ต ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ
๐Ÿ’ป Computer Science/- Data Structure, Algorithm

[์•Œ๊ณ ๋ฆฌ์ฆ˜ PS] ๋ฐฑ์ค€ 1476๋ฒˆ ๋‚ ์งœ ๊ณ„์‚ฐ ์ž๋ฐ” ๋ฌธ์ œํ’€์ด

by Wonit 2021. 2. 14.

๋ฌธ์ œ

ํ•ด๋‹น ํฌ์ŠคํŒ…์€ ๋ฐฑ์ค€์˜ 1476๋ฒˆ ๋‚ ์งœ ๊ณ„์‚ฐ ์˜ ์ ‘๊ทผ๊ณผ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•œ ๊ธ€ ์ž…๋‹ˆ๋‹ค.
์ •๋‹ต ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ํ™•์ธํ•˜์‹œ๋ ค๋ฉด solve url ์—์„œ ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด ์–ด๋–ค ๋ฐฉ์‹์œผ๋กœ ์ ‘๊ทผํ•ด์•ผ ํ•˜๋Š”์ง€๋ฅผ ๋จผ์ € ์ƒ๊ฐํ•ด๋ณด์ž.

๋ฌธ์ œ ์ ‘๊ทผ

์ด๋ฒˆ ๋ฌธ์ œ๋Š” ์™„์ „ ํƒ์ƒ‰์˜ ๊ฐ€์žฅ ๊ธฐ์ดˆ์ ์ธ ๋ฌธ์ œ๋กœ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

 

์™„์ „ ํƒ์ƒ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๊ธฐ๋ฒ• ์ค‘ ๋ธŒ๋ฃจํŠธ ํฌ์Šค ์ ‘๊ทผ์œผ๋กœ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ๋‹ค.

 

๋ธŒ๋ฃจํŠธ ํฌ์Šค ์•Œ๊ณ ๋ฆฌ์ฆ˜์€ ์‹œ๊ฐ„ ๋ฉด์—์„œ ๊ฐ€์žฅ ๋น„ํšจ์œจ์ ์ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด์ง€๋งŒ, ๊ฐ€์žฅ ํ™•์‹คํ•œ ๋ฐฉ๋ฒ•์œผ๋กœ ์•Œ๋ ค์ ธ ์žˆ๋‹ค.

ํ•ด๊ฒฐ๋ฒ•

์ด ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” E, S, M ์ด 1๋…„์ด ์ฆ๊ฐ€ํ•  ๋•Œ ๋งˆ๋‹ค 1์”ฉ ์ฆ๊ฐ€ํ•˜๋Š” ํŠน์„ฑ์„ ์ด์šฉํ•œ๋‹ค.

 

์šฐ์„  ์ž…๋ ฅ๋ฐ›์„ E, S, M๊ณผ ๋˜‘๊ฐ™์€ e, s, m ๋ณ€์ˆ˜๋ฅผ ํ•˜๋‚˜ ๋” ๋งŒ๋“ค์–ด ์ค€๋‹ค.

 

์šฐ๋ฆฌ์˜ e, s, m์„ ๊ฐ๊ฐ 1์”ฉ ๊ณ„์† ์ฆ๊ฐ€์‹œ์ผœ์„œ ์ž…๋ ฅ๋ฐ›์€ E, S, M๊ณผ ๊ฐ™์„ ๋•Œ ๊นŒ์ง€ ์นด์šดํŒ…์„ ํ•˜๋ฉด ๋์ด๋‹ค.

์ •๋‹ต ์ฝ”๋“œ

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] esm = br.readLine().split(" ");

        int E = Integer.parseInt(esm[0]);
        int S = Integer.parseInt(esm[1]);
        int M = Integer.parseInt(esm[2]);
        int count = 1;
        int e = 1;
        int s = 1;
        int m = 1;

        while(true) {
            if(E==e && S==s && M==m) break;
            e++; s++; m++;

            if(e == 16) e = 1;
            if(s == 29) s = 1;
            if(m == 20) m = 1;

            count++;
        }
        bw.write(String.valueOf(count));
        bw.flush();
        bw.close();
    }
}

์ •๋‹ต ์†Œ์Šค ์ฝ”๋“œ๋ฅผ ํ™•์ธํ•˜์‹œ๋ ค๋ฉด solve url ์—์„œ ํ™•์ธ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

๋Œ“๊ธ€