hdoj.1295 Move Move Look【水题】 2015/08/06
来源:互联网 发布:上海的美食知乎 编辑:程序博客网 时间:2024/05/16 12:09
Move Move Look
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 853 Accepted Submission(s): 542
Problem Description
There are two color (white and black) chessmen in a row. The number of white chessman is equal to the number of black chessman. The left half of the row is black chessmen and the right half of the row is white chessmen at first. There are two rules for the game.
1. Only two neighbor chessmen (double black, double white or one black and one white) can be moved to vacancy at one time. The new vacancy can be filled by the two new neighbor chessmen. Repeat moving chessmen until all chessmen are interphase with black chessman and white chessman.
2. The number of move must be the minimum.
The case n=3 is shown in Fig. 1. Your task is to get the number of the minimum steps.
1. Only two neighbor chessmen (double black, double white or one black and one white) can be moved to vacancy at one time. The new vacancy can be filled by the two new neighbor chessmen. Repeat moving chessmen until all chessmen are interphase with black chessman and white chessman.
2. The number of move must be the minimum.
The case n=3 is shown in Fig. 1. Your task is to get the number of the minimum steps.
Input
There are multiple cases in this problem and ended by the EOF. In each case, there is only one integer means the number of black chessmen (the same as white chessmen) n(3<=n<=1000).
Output
For each test case, there is only one integer means the minimum steps.
Sample Input
3
Sample Output
3
Author
SmallBeer(CML)
Source
杭电ACM集训队训练赛(VIII)
n = 4 时:
0 0 0 0 1 1 1 1
0 0 1 1 1 1 0 0
0 1 1 0 1 1 0 0
0 1 1 0 1 0 1 0
1 0 1 0 1 0 1 0
0 0 0 0 1 1 1 1
0 0 1 1 1 1 0 0
0 1 1 0 1 1 0 0
0 1 1 0 1 0 1 0
1 0 1 0 1 0 1 0
#include<iostream>#include<cstdio>using namespace std;int main(){ int n; while( ~scanf("%d",&n) ){ printf("%d\n",n); } return 0;}
0 0
- hdoj.1295 Move Move Look【水题】 2015/08/06
- hdu 1295 Move Move Look
- Move Move Look
- hdu 1295 Move Move Look 数学问题,代码能猜出来,思路想不通
- Move
- Move
- Move
- Move..
- Move!Move!!Move!!!
- Move.c && Move.h
- Move.h && Move.c
- Move on
- Move函数
- ----Move on-----
- move 操作
- Move Type
- Oracle9i - move
- MOVE语句。
- hdu 1686 Oulipo(kmp)
- 提升tomcat服务器性能的七条经验
- Java4Android-包和访问权限2
- HDU 4323
- 由二叉树前序和中序遍历生成二叉树
- hdoj.1295 Move Move Look【水题】 2015/08/06
- sql触发器(insert,update,delete)
- 【Cocos2d入门教程三】HelloWorld之一目了然
- iOS开发课程免费得
- MySQL基础语句
- HTML <a> 标签 (修改样式,链接邮箱Email地址)
- 矩形覆盖
- 16. Element contentEditable 属性
- C++Primer 第五版 练习9.43 解答