poj 2605 Simple game on a grid
2011-11-22 12:52
281 查看
Simple game on a grid
Description
There is an infinite grid and an m*n rectangle of stones on it (1 <= m,n <= 1000). The stones are located in the knots of the grid.
A following game for a single player is being played. One stone can jump over another along a vertical or a horizontal line. A stone which had been overjumped is taken away. The purpose of the game is to minimize number of stones on a grid.
Given a pair of numbers m and n separated with one space in an input file you are to write a program which should determine a minimal number of the stones left on the grid.
Input
Numbers m and n separated by space.
Output
The minimal number of the stones left on the grid.
Sample Input
Sample Output
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 847 | Accepted: 435 |
There is an infinite grid and an m*n rectangle of stones on it (1 <= m,n <= 1000). The stones are located in the knots of the grid.
A following game for a single player is being played. One stone can jump over another along a vertical or a horizontal line. A stone which had been overjumped is taken away. The purpose of the game is to minimize number of stones on a grid.
Given a pair of numbers m and n separated with one space in an input file you are to write a program which should determine a minimal number of the stones left on the grid.
Input
Numbers m and n separated by space.
Output
The minimal number of the stones left on the grid.
Sample Input
3 4
Sample Output
2
#include <stdio.h> int main() { int m,n,t; while(scanf("%d%d",&m,&n)!=EOF) { if(n>m) {t=n;n=m;m=t;} if(n==1 || n==2) printf("%d\n",(m+1)/2); else if(n%3==0 || m%3==0) printf("2\n"); else printf("1\n"); } return 0; }
相关文章推荐
- POJ 2605 Simple game on a grid 笔记
- [构造 找规律 孔明棋] Ural 1051 Simple Game on a Grid
- URAL 1051 Simple Game on a Grid
- POJ 1942 Paths on a Grid 组合数学
- POJ 1942:Paths on a Grid
- 【poj 1942】Paths on a Grid 组合数学
- Paths on a Grid(POJ--1942
- poj 1942 Paths on a Grid
- Something about 博弈(POJ 3922 A simple stone game)
- POJ 1942 Paths on a Grid
- POJ 1942 Paths on a Grid
- POJ 1942 Paths on a Grid
- poj 1942 Paths on a Grid
- [ACM] POJ 1942 Paths on a Grid (组合)
- POJ-1942 Paths on a Grid 组合数
- poj 1942 Paths on a Grid
- poj 1942 Paths on a Grid
- POJ 3922 A simple stone game 已被翻译
- HDU 2486 (HDU 2580, POJ 3922) A simple stone game K倍动态减法游戏
- POJ 1942 Paths on a Grid【组合数学】