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

int 不够, 要用_int64 or long long

Posted by sunmoonstar at 2006-08-16 19:54:22 on Problem 2961
In Reply To:为什么会output limit exceed?帮忙看看啊!!!! Posted by:y05hcy at 2006-08-16 15:11:07
> #include<iostream.h>
> int H[2][2]={{1,1},{1,-1}};
> int change(int j,int k);
> void main()
> {
> 	int nn,n,x,y,w,h;
> 	int i,j,k;	
> 	cin>>nn;
> 	for(i=0;i<nn;i++)
> 	{
> 		cin>>n>>x>>y>>w>>h;
>         for(j=y;j<y+h;j++)
> 		{
> 			for(k=x;k<x+w;k++)
> 			{			
> 				cout<<change(j,k);
> 				if(k+1<x+w) cout<<' ';
> 			}
> 			cout<<endl;
> 		}
> 		cout<<endl;
> 	}
> }
> int change(int j,int k
> 		   )
> {
> 	if(k<2 && j<2) return H[j][k];
> 	else
> 	{
> 		int p=0,q=0;
> 		if(k>=2)
> 		{
> 			p=2;
> 			while(k>=p)
> 			{
> 				p*=2;
> 			}
> 			p/=2;
> 			k-=p;
> 		}
> 		if(j>=2)
> 		{
> 			q=2;
> 			while(j>=q)
> 			{
> 				q*=2;
> 			}
> 			q/=2;
> 			j-=q;
> 		}
> 		if(p==q) return -1*change(j,k);
> 		else if(p>q) return change(j+q,k);
> 		else return change(j,k+p);
> 	}
> }

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