Created
March 23, 2016 19:36
-
-
Save HyeonWooKim/12cedee66c5032977fbb to your computer and use it in GitHub Desktop.
제곱ㄴㄴ수(BOJ 1016)
This file contains 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> | |
#include<vector> | |
using namespace std; | |
bool f[5555555]; | |
int main() | |
{ | |
vector<long long> v; | |
long long a,b,len,ans=0; | |
cin>>a>>b; | |
for(long long i=2;i*i<=b;i++) v.push_back(i*i); | |
len=v.size(); | |
for(int i=0;i<len; i++) | |
{ | |
for(long long j=(a/v[i])*v[i];j<=b;j+=v[i]) | |
{ | |
if(j-a>=0 && !f[j-a]) | |
f[j-a]=1,ans++; | |
} | |
} | |
cout<<b-a-ans+1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment