M.cpp 371 B

123456789101112131415161718
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. bool Primer(int n){
  4. if(n==2)return true;
  5. if(n<2||n%2==0)return false;
  6. for(int c=3;c*c<=n;c+=2)if(n%c==0)return false;
  7. return true;
  8. }
  9. int main(){
  10. int n;cin>>n;
  11. int tot=0;
  12. if(n>=3)++tot;
  13. for(int p=3;p+2<=n;p+=2){
  14. if(Primer(p)&&Primer(p+2))++tot;
  15. }
  16. cout<<tot<<endl;
  17. return 0;
  18. }