src2020/3069_includesushu/wrong.cpp

37 lines
701 B
C++

#include <iostream>
#include <vector>
using namespace std;
vector<int> su;
bool pan(int n)
{
if(n==1){
return 1;
}
for (int i = 0; i < su.size(); i++) {
if (n % su[i] == 0 || su[i] * su[i] > n) {
return 0;
}
}
su.push_back(n);
return 1;
}
int main()
{
int begn, ends;
cin >> begn >> ends;
int bgnum=1,ednum=1;
/*if(pan(begn)==1){
bgnum--;
}*/
for (int i = 2; i * i <= ends; i++) {
if (pan(i) == 1) {
if (i * i <= begn) {
bgnum+=begn/i+i-2;
}
ednum+=ends/i+i-2;
}
}
cout<<ends-ednum-begn+bgnum;
}