반응형

문제 출처 :


https://www.acmicpc.net/problem/14625



알고리즘 분석 :


문제 해결에 필요한 사항

1. 구현


단순 구현을 통해 문제를 해결 할 수 있다.


hh와 mm을 h1h2와 m1m2로 나타냈을 때


h1 == n || h2 == n || m1 == n || m2 == n인 경우 ans += 1을 해주면 정답을 구할 수 있다.


이때 입력이

2 30

2 30

0

이라면 답은 1임을 기억하고 문제를 해결하자. 




소스 코드 : 


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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <cstdio>
 
using namespace std;
 
int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
 
    int n;
    cin >> n;
 
    int ans = 0;
    while (1)
    {
        if (a % 10 == n || a / 10 == n || b % 10 == n || b / 10 == n )
            ans++;
        if (a == c && b == d)
            break;
 
        b++;
        if (b == 60)
        {
            b = 0;
            a++;
        }
    }
 
    cout << ans << endl;
 
    return 0;

}
 
//                                                       This source code Copyright belongs to Crocus
//                                                        If you want to see more? click here >>
Crocus


반응형

'Applied > 알고리즘 문제풀이' 카테고리의 다른 글

[1080번] 행렬  (0) 2017.12.01
[14626번] ISBN  (0) 2017.11.30
[5884번] 감시 카메라  (0) 2017.11.29
[1062번] 가르침  (3) 2017.11.28
[2533번] 사회망 서비스(SNS)  (2) 2017.11.24