https://www.acmicpc.net/problem/1016
#include <vector>
#include <iostream>
#include <string>
#include <sstream>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <stack>
#include <unordered_map>
#include <set>
#include <regex>
#include <tuple>
#include <cmath>
#include <cstddef>
using namespace std;
int main(void)
{
ios::sync_with_stdio(false);
cin.tie(NULL);
std::cout.tie(NULL);
long min, max;
cin >> min >> max;
vector<bool> check(max - min + 1);
for (long i = 2; i * i <= max; i++)
{
long pow = i * i;
long start_idx = min / pow;
if (min % pow != 0)
start_idx++;
for (long j = start_idx; pow * j <= max; j++)
check[(int)((j * pow) - min)] = true;
}
int cnt = 0;
for (int i = 0; i <= max - min; i++)
if (!check[i])
cnt++;
cout << cnt << endl;
return 0;
}'콘솔창 & 윈도우창 > 코딩 테스트' 카테고리의 다른 글
| 프로그래머스 LV.2 튜플 (0) | 2026.01.07 |
|---|---|
| LV.2 미로탈출 (0) | 2025.10.26 |
| [백준 실버 1] 1741 소수&팰린드롬 (0) | 2025.08.09 |
| 회문 순열 (2) | 2025.08.07 |
| 코딩 인터뷰 문제 6가지 (4) | 2025.08.03 |