i dont knw wt wrong i have done in this simple problem bt its nt being
accepted at uva judge
here is the link to the problem

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=6&page=show_problem&problem=347

please help me debug my code


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main()
{
    int N,C;// the inputs to be scanned
    vector<int>primes;//prime array
    vector<int>s;

    while(scanf("%d %d",&N,&C)==2)
    {
    int i,j,k;// counters
    primes.clear();
    s.clear();
    for(i=0;i<=N;i++)
    primes.push_back(i);

    for(i=2;i<primes.size();i++)
    {
      for(j=2;i*j<primes.size();j++)
      primes[i*j]=0;
    }

    for(i=0;i<primes.size();i++)
    {
       if(primes[i]!=0)
       s.push_back(i);
    }

   /* for(i=0;i<s.size();i++)
    cout<<s[i]<<endl;*/
    printf("%d\n",s.size());
    printf("%d %d: ",N,C);

    if((2*C)>s.size())
    {
      for(i=0;i<s.size();i++)
      printf("%d ",s[i]);
    }

    else if((s.size())%2==0)
    {
      // the evaluate the number of prime numbers to be left out
      j=(s.size()-2*C)/2;

      for(i=j;i<(j+2*C);i++)
      printf("%d ",s[i]);
    }

    else
    {
        j=(s.size()-2*C+1)/2;
        for(i=j;i<(j+2*C-1);i++)
        printf("%d ",s[i]);
    }

    printf("\n");
    }

    getchar();
    getchar();

    return 0;
}

thnxx in advance

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to