http://poj.org/problem?id=3292
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
const int N=1000001;
int ans[N];
void findans()
{
memset(ans,0,sizeof(ans));
for(int i=5;i<N;i+=4)
{
for(int j=5;j<N;j+=4)
{
int temp=i*j;
if(temp>=N)
break;
if(ans[i]==0&&ans[j]==0)
{
ans[temp]=1;
}
else
{
ans[temp]=-1;
}
}
}
int sum=0;
for(int i=1;i<N;++i)
{
if(ans[i]==1)
++sum;
ans[i]=sum;
}
}
int main()
{
findans();
int n;
while(cin>>n)
{
if(n==0)
break;
cout<<n<<" "<<ans[n]<<endl;
}
return 0;
}