水题,给出一个数n,求在1到n中,刚好是由两个模4余1的素数相乘得到的数有多少个
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <stdlib.h>
using namespace std;
const int size=1000001;
int H_number[size+1];
int H[size+1];
void isH_number()
{
memset(H_number,0,sizeof(H_number));
for(int i=5;i<=size;i+=4)
for(int j=5;j<=size;j+=4)
{
int m=i*j;
if(m>size)break;
if(H_number[i]==0&&H_number[j]==0)H_number[m]=1;
else H_number[m]=-1;
}
int count=0;
for(int i=1;i<=size;i++)
{
if(H_number[i]==1)count++;
H[i]=count;
}
}
int main()
{
isH_number();
int n;
while(cin>>n&&n)
{
cout<<n<<' '<<H[n]<<endl;
}
return 0;
}