POJ 2605 数学
来源:互联网 发布:软件开发工艺流程 编辑:程序博客网 时间:2024/05/22 11:38
http://poj.org/problem?id=2605
Simple game on a grid
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 931 Accepted: 482
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.
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
Source
Ural State University collegiate programming contest 2000
题目大意:
给你一个n*m的矩阵,尽可能多的消去里面所有的石头,最后剩下几颗
其实就是找规律,表示和同学一起也找了半天
①如果是3*n的话,那么最后肯定能变成3*1的类型的,那么就是剩下两个。
②如果是2*n(n不能被3整除)或者是1*n(同2*n)的话,那么就是(n+1)/2。
③如果是4*n,5*n(n不能被3整除,且大于2)的话,那么就也只是剩下一个。(具体的操作自己去划一下才有感觉)
于是我们通过归纳得到,
当n大于3的时候,如果n和m在都不能被3整除,那么就是1。
当n=3的时候就是2
当n=1和2的时候就是(n+1)/2;
0 0
- POJ 2605 数学
- poj 数学
- POJ数学(ZZ)
- POJ数学题目
- POJ数学题目
- poj数学题目
- poj-1942-组合数学
- poj-1850-数学
- poj-3252-数学
- POJ数学强化
- poj 1844 数学问题
- poj 1840 (数学)
- poj数学问题归类
- POJ 1183 数学推导
- poj 1844 sum (数学)
- 数学-> YY POJ 1338
- poj 1862 Stripies 数学
- POJ数学题目
- 图像的小波变换
- java 调用 sqlite
- <canvas>学习笔记——绘制直线的API
- Spring核心机制-依赖注入
- 思维题目(nyoj47)
- POJ 2605 数学
- php显示动态时间源代码
- [备忘]Psycopg学习笔记(1)
- 内存缓存与LruCache
- 用Java写解谜Rpg-4.加载界面,RPG界面与Player
- 剑指offer-面试题58:二叉树的下一个结点
- BIOS、MBR、PBR等基础知识,兼谈U盘、移动硬盘以及操作系统的安装与启动基本原理
- android在ScrollView嵌套listview不能正常显示
- 【第四章】 资源 之 4.4 Resource通配符路径 ——跟我学spring3