A. Almost Prime
来源:互联网 发布:mac 梦幻西游手游网页 编辑:程序博客网 时间:2024/06/05 22:32
A. Almost Prime
time limit per test
2 secondsmemory limit per test
256 megabytesinput
standard inputoutput
standard outputA number is called almost prime if it has exactly two distinct prime divisors. For example, numbers 6, 18, 24 are almost prime, while 4, 8, 9, 42 are not. Find the amount of almost prime numbers which are between 1 and n, inclusive.
Input
Input contains one integer number n (1?≤?n?≤?3000).
Output
Output the amount of almost prime numbers between 1 and n, inclusive.
Sample test(s)
input
10
output
2
input
21
output
8
/* ***********************************************
Author :
Created Time :2015/6/12 14:48:26
File Name :7.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 3000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int used[maxn];
int f[maxn];
void Set(){
cle(f);
memset(used,1,sizeof(used));
for(int i=2;i<=maxn/2;i++){
if(used[i]){
used[i]=0;
for(int j=i+i;j<maxn;j+=i){
f[j]++;
used[j]=0;
}
}
}/*
for(int i=4;i<=40;i++){
cout<<f[i]<<" ";
if(i%7==0)cout<<endl;
}*/
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n;
Set();
while(cin>>n){
int cnt=0;
for(int i=5;i<=n;i++)
if(f[i]==2)cnt++;
cout<<cnt<<endl;
}
return 0;
}
0 0
- A. Almost Prime
- A. Almost Prime
- CF 26A-Almost prime
- 【详解打表】#26 A. Almost Prime
- Code Forces 26A Almost Prime
- codeforces-26A-Almost Prime【分解质因数】
- CodeForces 26 A.Almost Prime(数论)
- Codeforces Beta Round #26 (Codeforces format) A Almost Prime
- UVa10539 Almost Prime Numbers
- UVa10539 - Almost Prime Numbers
- UVA10539 - Almost Prime Numbers
- 10539 - Almost Prime Numbers
- 【codeforces26A】Almost Prime
- uva10539 Almost Prime Numbers
- Almost Prime Numbers UVA
- UVA 10539 Almost Prime
- Almost Prime Numbers UVA
- UVa 10539 - Almost Prime Numbers
- A. Jabber ID
- A. Second Order Statistics
- A. You\'re Given a String...
- A. Ring road
- A. IQ test
- A. Almost Prime
- A. Next Test
- Oracle内置表二
- A. Spit Problem
- A. Accounting
- A. Worms Evolution
- A. Reconnaissance
- 重新认识——CSS Position定位
- A. What is for dinner?