BZOJ1193 马步距离 (贪心)
2014-12-22 20:53
253 查看
恶心的题目= =
#include <cstdio> #include <cmath> #include <algorithm> int f[5][5]={{0,3,2,3,2},{3,2,1,2,3},{2,1,4,3,2},{3,2,3,2,3},{2,3,2,3,4}}; int main() { int a,b,c,d,x,y,ans=0; scanf("%d%d%d%d",&a,&b,&c,&d); x=abs(a-c); y=abs(b-d); while ((x>4)||(y>4) ) { if (x>y) {x-=2; y-=1;} else {x-=1; y-=2; } x=abs(x); y=abs(y); ans++; } if ((x<=4)&&(y<=4)) {printf("%d",ans+f[x][y]); return 0;} while ((x==1)&&(y>=4)) { x-=1; y-=2; ans++; } while ((y==1)&&(x>=4)) { x-=2; y-=1; ans++; } while ((x==0)&&(y>=4)) { y-=4; ans+=2; } while ((y==0)&&(x>=4)) { x-=2; ans+=2; } ans+=f[x][y]; printf("%d",ans); }
相关文章推荐
- [BZOJ1193][HNOI2006]马步距离(贪心+dfs)
- [BZOJ1193][HNOI2006]马步距离 大范围贪心小范围爆搜
- 【bzoj1193】【HNOI2006】【马步距离】【贪心+bfs】
- BZOJ 1193 马步距离(贪心 乱搞)
- [BZOJ1193][HNOI2006]马步距离(贪心+BFS)
- bzoj 1193: [HNOI2006]马步距离(贪心+BFS)
- [bzoj 1193--HNOI2006]马步距离
- bzoj1193 马步距离
- BZOJ 1193: [HNOI2006]马步距离
- bzoj 1193 【HNOI2006】马步距离
- bzoj1193 [HNOI2006]马步距离
- 【bzoj1193】[HNOI2006]马步距离
- 【BZOJ 1193】 [HNOI2006]马步距离
- BZOJ1193: [HNOI2006]马步距离
- 1193: [HNOI2006]马步距离 (贪心+搜索)
- bzoj 1193: [HNOI2006]马步距离
- 【BZOJ 1193】 [HNOI2006]马步距离
- bzoj1193: [HNOI2006]马步距离
- BZOJ1193: [HNOI2006]马步距离
- 【HNOI2006】【BZOJ1193】马步距离