2008年9月27日星期六

First TopCoder Program (SRM 291 DIV II)

I am still confused about string and vector and how to calculate the score( I got 95 out of 250, but why?).....I won't give up.
PS: it's really painful to change Pascal to C++. It's ulgy to dispaly my code in Blogger...

#include

class FarFromPrimes{
public:

int count(int A, int B);
{
int s[100000];
int flag;
int ans=0;
for (int i=0;i<=100000;i++)
s[i]=0;
for (int i=2;i<=317;i++)
{
if (s[i]==0)
{
for (int j=2;j<=100000/i;j++)
s[i*j]=1;
}
}
for (int i=A;i<=B;i++)
{
flag=0;
for (int j=i-10;j<=i+10;j++)
if (s[j]==0)
{
flag=1;
break;
}
if (flag==0)
ans++;
}
return ans;
}
}

没有评论: