Created
July 14, 2019 11:54
-
-
Save surinoel/4b1c4def5179b5148d9229d5f144266e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
bool ok[1000001]; | |
int main(void) { | |
ios_base::sync_with_stdio(false); | |
cin.tie(nullptr); | |
long long n, m; | |
cin >> n >> m; | |
for (long long i = 2; i*i <= m; i++) { | |
long long st; | |
if (n%(i*i) == 0) { // 시작점이 제곱수라면 | |
st = n; | |
} | |
else { // 시작점이 제곱수가 아닐 시 나머지를 빼주고, 제곱수만큼 더해줘서 시작 | |
st = n - (n%(i*i)) + i*i; | |
} | |
for (long long j = st; j <= m; j += i*i) { | |
ok[j - n] = true; | |
} | |
} | |
int ans = 0; | |
for (int i = 0; i <= m - n; i++) { | |
if (!ok[i]) ans += 1; | |
} | |
cout << ans << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment