5의 개수를 세는 것이 핵심적인 문제, 600까지가 조건이므로 5의 세제곱까지만 신경쓰면 되겠다. 


#include <iostream>


int main()

{

int input;

int ans = 0;

std::cin >> input;

for (int i = 1; i <= input; ++i)

{

if (i % 5 == 0)

++ans;

if (i % 25 == 0)

++ans;

        if(i % 125 == 0)

            ++ans;

}

std::cout << ans << std::endl;

return 0;

}

'백준 온라인 저지' 카테고리의 다른 글

백준 11724: 연결요소의 개수  (0) 2018.07.15
백준 1260: DFS와 BFS  (0) 2018.07.15
백준 6588: 골드바흐의 추측  (0) 2018.07.13
백준 1929: 소수구하기(충격의 endl)  (0) 2018.07.13
백준 1978: 소수 찾기  (0) 2018.07.13

+ Recent posts