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

这样呀!

Posted by 6754228 at 2007-12-16 21:58:58 on Problem 3364
In Reply To:这题用什么算法好啊?我用递归Memory: 1636K Time: 390MS,太差劲了 Posted by:dllgwgy at 2007-09-21 11:01:51
#include <iostream>
using namespace std;

int f( int m,int n,int x)
{
	if( m%2==0||n%2==0  )
		return m*n/2;
    if( x==0 )
		    return (m-1)*n/2 + (n-1)/2;
	return (m-1)*n/2 + (n+1)/2;

}

int main()
{
   int m,n,x;
   
   while( cin>>m>>n>>x&& !(m<8))
   {   
       if(x==1) 
	        cout<<f(m-7,n-8,1-x) + f(m-8,n-7,1-x) - f(m-8,n-8,x)+1<<endl;
       else 
		   cout<<f(m-7,n-8,1-x) + f(m-8,n-7,1-x) - f(m-8,n-8,x)<<endl;
   }
   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