Browse Source

Add 'M.cpp'

webturing 4 years ago
parent
commit
95ffc3b475
1 changed files with 18 additions and 0 deletions
  1. 18 0
      M.cpp

+ 18 - 0
M.cpp

@@ -0,0 +1,18 @@
+#include<bits/stdc++.h>
+using namespace std;
+bool Primer(int n){
+    if(n==2)return true;
+    if(n<2||n%2==0)return false;
+    for(int c=3;c*c<=n;c+=2)if(n%c==0)return false;
+    return true;
+}
+int main(){
+    int n;cin>>n;
+    int tot=0;
+    if(n>=3)++tot;
+    for(int p=3;p+2<=n;p+=2){
+        if(Primer(p)&&Primer(p+2))++tot;
+    }
+    cout<<tot<<endl;
+    return 0;
+}