| ||||||||||
| 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 | |||||||||
Re:这题怎么节省时间,我按照经典的叉积方法实现,却用了500多ms,请问15ms的是怎么搞的?In Reply To:这题怎么节省时间,我按照经典的叉积方法实现,却用了500多ms,请问15ms的是怎么搞的? Posted by:liyineng at 2006-07-30 12:14:45 > 这题怎么节省时间,我按照经典的叉积方法实现,却用了500多ms,请问15ms的是怎么搞的?
同问!!!!
下面的写法还能优化么?
scanf("%c", &dir);
switch(dir)
{
case '1':nx = lx-1; ny = ly-1;break;
case '2':nx = lx; ny = ly-1;break;
case '3':nx = lx+1; ny = ly-1;break;
case '4':nx = lx-1; ny = ly;break;
case '5':break;
case '6':nx = lx+1; ny = ly;break;
case '7':nx = lx-1; ny = ly+1;break;
case '8':nx = lx; ny = ly+1;break;
case '9':nx = lx+1; ny = ly+1;break;
}
res += nx*ly-lx*ny;
lx = nx; ly = ny;
if(dir == '5')
break;
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator