| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
这样呀!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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator