Skip to content

Commit

Permalink
Almost Prime
Browse files Browse the repository at this point in the history
  • Loading branch information
seikhchilli committed May 3, 2024
1 parent 1fc9023 commit 7f5781d
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 26A.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//4240326 Aug 7, 2013 5:13:59 PM fuwutu 26A - Almost Prime GNU C++0x Accepted 30 ms 0 KB
#include <cstdio>

int main()
{
int n, amount(0);
scanf("%d", &n);

bool b[3001] = {false};
int pfactors[3001] = {0};
for (int i = 2; i <= n; ++i)
{
if (!b[i])
{
for (int j = i + i; j <= n; j += i)
{
b[j] = true;
pfactors[j] += 1;
}
}

if (pfactors[i] == 2)
{
amount += 1;
}
}
printf("%d\n", amount);
return 0;
}

0 comments on commit 7f5781d

Please sign in to comment.