ZOJ-2954
来源:互联网 发布:mac移动硬盘隐藏文件 编辑:程序博客网 时间:2024/05/17 23:52
模拟题,无算法,细心处理细节就行
#include<stdio.h>int main(){int t, n, m, tower[4][10], count[4];scanf("%d", &t);while (t--){int from, to, i, finish = 0;scanf("%d %d", &n, &m);count[1] = n, count[2] = count[3] = 0;for (i = 0; i < n; i++)tower[1][i] = n - i;for (i = 1; i <= m; i++){scanf("%d %d", &from, &to);if (finish)continue;if (count[from]&& (count[to] == 0|| (count[to]&& tower[from][count[from] - 1]< tower[to][count[to] - 1]))){tower[to][count[to]++] = tower[from][--count[from]];if (to == 3 && count[3] == n){printf("%d\n", i);finish = 1;}}else{printf("%d\n", -i);finish = 1;}}if (!finish)puts("0");}return 0;}
0 0
- zoj 2954
- ZOJ-2954
- zoj 2954 Hanoi Tower
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- 常用java学习网站收藏
- cocos2d(CCSprite绑定不规则刚体与精灵一起移动)
- 虚函数精解
- C/C++指针+1的计算
- python 线程,GIL 和 ctypes
- ZOJ-2954
- leetcode-Binary Tree Level Order Traversal II(2014.1.27)
- poj3615
- leetcode-Binary Tree Level Order Traversal(2014.1.22)
- java通过实体类自动生成ibatis文件
- 常见C++内存池技术
- linux 调用动态库so文件
- GCC内嵌汇编语言
- 《算法导论》之堆排序学习心得