Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:这题sample的数据挺全了。。

Posted by jackie_wyx at 2006-11-27 20:46:08 on Problem 3006
In Reply To:这题sample的数据挺全了。。 Posted by:Acsaga at 2006-11-27 20:42:11
可是我的都过了啊
可是还是WA
#include <stdio.h>

int c[10000000]={0};

main()
{
  int a,d,n,i,j,k;

  for(i=2;i<=1000000;i++)
  {
    if(c[i]==0)
    {
      for(j=i*2;j<=1000000;j=j+i) c[j]=1;
    }
  }
  scanf("%d%d%d",&a,&d,&n);
  while(a!=0 || d!=0 || n!=0)
  {
    k=0;
    j=-1;
    while(k<n)
    {
      j++;
      if(c[a+j*d]==0) k++;
    }
    printf("%d\n",a+j*d);
    scanf("%d%d%d",&a,&d,&n);
  }
  
  return(0);
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator