출처: https://bumcrush.tistory.com/182 [맑음때때로 여름]

상세 컨텐츠

본문 제목

백준 1065 한수(brute force)

알고리즘

by 장동균 2020. 4. 14. 21:57

본문

d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;
 
int main()
{
    int num;
    cin>>num;
    int count=0;
    for(int i=1;i<=num;i++)
    {
        if(i<100)
        count++;
        else if(i>=100&&i<1000)
        {
            if(((i/100)-(i%100/10))==((i%100/10)-(i%10)))
            count++;
        }
    }
    cout<<count;;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

먼저, 100미만의 수는 반드시 한수를 이룬다. 들어올 수 있는 수는 1000미만임으로 우리는 3자리의 자연수만 고려해주면 되었다.

관련글 더보기

댓글 영역