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

hawk请进,这道题我用上交大的数据测了,没有错,为什么老是wa?

Posted by yinsheng at 2005-04-10 19:41:14 on Problem 2081
#include <stdio.h>
#include <stdlib.h>
#include <set>
using namespace std;
int main(int argc, char *argv[])
{
  //FILE * in;
  //FILE * out;
  //in=fopen("recaman.in","r");
  //out=fopen("out.txt","w");
  set<long> h[100000];
  long t,i,k,a;
  scanf("%d",&k);
  while (k!=-1) {
   t=0;
   for(i=0;i<100000;i++) h[i].clear();
   for(i=1;i<=k;i++) 
  	  if ((t-i>0)&&(h[(t-i) % 100000].find(t-i)==h[(t-i) % 100000].end()))
  	      {
  	      	t=t-i;
  	      	h[t % 100000].insert(t);
  	      }
  	  else
  	     {
            t=t+i;
  	      	h[t % 100000].insert(t);
  	      }
    printf("%d",t);
  	scanf("%d",&k);
  	if (k!=-1) printf("\n");
  }
  //fclose(out);
  //system("PAUSE");	
  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