Skip to content

Commit

Permalink
solve 4948
Browse files Browse the repository at this point in the history
  • Loading branch information
ykss committed Apr 5, 2019
1 parent c174915 commit 62dae64
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions problems/4948/21300875_4948.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <iostream>
#include <vector>

using namespace std;

bool isprime(int n) {
if(n < 2) return false;
for(int i=2; i*i<=n; i++){
if (n%i == 0)
return false;
}
return true;
}

int main() {
int N = 0;
vector<int> v;
while(1){
int cnt = 0;
cin >> N;
if(N==0) break;
for(int i=N+1;i<=2*N;i++){
if(isprime(i)) cnt++;
}
v.push_back(cnt);
}

for(int i=0;i<v.size();i++){
cout << v[i] << endl;
}

return 0;
}

0 comments on commit 62dae64

Please sign in to comment.