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

对于这些数据,我用一个精度更低的程序(看看,只要把p,r设为double就可)都可以符合你给的result,但是同样WA.

Posted by zxqi_009 at 2005-08-02 11:39:03 on Problem 2514
In Reply To:测了10000组,结果见内 Posted by:c0500448242 at 2005-08-01 20:36:29
#include<iostream>

using namespace std;

double p,r;
__int64 s[20],q[15],k1,k2,k;

int s_i,q_i;


int sum(__int64 k,__int64 *s,int s_i,int sign)
{		k1=0;
		__int64 temp,temp1,begin1,begin,end,mid;
		
		while(k1<k)
		{   
			temp=(s[s_i+1]-s[s_i])*s_i;
			if(k1+temp<k)
		     {k1+=temp; s_i++;}
		    else break;
		    
		}
		if(k1+temp==k)
		{ 
		  if(sign==0)temp1=(s[s_i+1]-1)*(s[s_i+1]-1);
		  else temp1=s[s_i+1]-1;
		  //int temp2=temp1;
		  p=temp1;
		  k=k1;
		}
	  else
	  {   begin=s[s_i],end=s[s_i+1]-1,begin1=begin;
		  while(begin<=end)
		  {  
			  mid=(begin+end)/2;
			  if((mid-begin1+1)*s_i+k1>k)
			  {
				if((mid-begin1)*s_i+k1<k)
				{   if(sign==0)p=mid*mid;
				    else p=mid;
					k1+=(mid-begin1+1)*s_i;
					break;
				}
				else end=mid-1;
			}
			else if((mid-begin1+1)*s_i+k1<k)
			{
				if((mid-begin1+2)*s_i+k1>k)
				{   if(sign==0)p=(mid+1)*(mid+1);
				    else p=mid+1;
					k1+=(mid-begin1+2)*s_i;
					break;
				}
				else begin=mid+1;
			}
			else 
			{   if(sign==0)p=mid*mid;
			    else p=mid;
				k=k1;
				break;
			}
		}
	  }
     for(int i=0;i<k1-k;i++)
		p/=10;
	 __int64 temp2=p;
	 return temp2%10;
}

int sum1(__int64 k)
{
	int Sum=sum(k,s,1,0)+sum(k,q,1,1);
	return Sum;
}

int Inc(__int64 k)
{
	int m=1,t=1;
	   while(t)
	   { 
		   int temp=sum1(k+m);
	   while(temp>9)
	   {
		   m++;
		   temp=sum1(k+m);
	   }
	     t=0;
	   if(temp==9&&sum1(k+m+1)>9)
		   m+=2;
	    
	   }
	   while(m>1)
	   {
		   t=(t+sum1(k+m-1))/10;
		   m--;
	   }
  return t;
}

int  main()
{  // int j;
	s[1]=1,s[2]=4,s[3]=10,s[4]=32,s[5]=100,s[6]=317,s[7]=1000,s[8]=3163,s[9]=10000,s[10]=31623;
	s[11]=100000,s[12]=316228,s[13]=1000000,s[14]=3162278,s[15]=10000000,s[16]=31622777,s[17]=100000000;
	s[18]=316227767,s[19]=1000000000;
    
	q[1]=1,q[2]=10,q[3]=100,q[4]=1000,q[5]=10000,q[6]=100000,q[7]=1000000,q[8]=10000000,q[9]=100000000;
	q[10]=1000000000,q[11]=10000000000,q[12]=100000000000,q[13]=1000000000000,q[14]=10000000000000;
	
//	cout<<sum(10,q,1,1);
/*
for(int jj=1;jj<100000000;jj+=78)
{	for(j=jj;j<79+jj;j++)
		cout<<sum(j,q,1,1);
	cout<<endl;
	for(j=jj;j<79+jj;j++)
		cout<<sum(j,s,1,0);
	cout<<endl;
    for(j=jj;j<79+jj;j++)
		cout<<(sum1(j)+Inc(j))%10;
	cout<<endl;

	cout<<endl;

	if(j%1000==0)
	{
		int j1=0;

	}
}
*/
//for(k=100000000;k<100090000;k++)	
   scanf("%I64d",&k);
   while(k)
   {
		cout<<(sum1(k)+Inc(k))%10;
      cout<<endl;
	 scanf("%I64d",&k);
   }
    

  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