HDU 5100 Chessboard 用 k × 1 的矩形覆盖 n × n 的正方形棋盘
2017-07-10 13:36
585 查看
点击打开链接
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 335 Accepted Submission(s): 168
Problem Description
Consider the problem of tiling an n×n chessboard by polyomino pieces that are k×1 in size; Every one of the k pieces of each polyomino tile must align exactly with one of the chessboard squares. Your task is to figure out the maximum number of chessboard squares
tiled.
Input
There are multiple test cases in the input file.
First line contain the number of cases T (T≤10000).
In the next T lines contain T cases , Each case has two integers n and k. (1≤n,k≤100)
Output
Print the maximum number of chessboard squares tiled.
Sample Input
Sample Output
Source
BestCoder Round #17
用 k × 1 的小矩形覆盖一个 n × n 的正方形棋盘,问正方形棋盘最多能被覆盖多少。
规律就是:假设n<k。肯定不行。
定义mod=n%k;
假设(mod<=k/2),结果为:n*n-mod*mod;
否则结果为:n*n-(k-mod)*(k-mod);
点此证明
Chessboard
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 335 Accepted Submission(s): 168
Problem Description
Consider the problem of tiling an n×n chessboard by polyomino pieces that are k×1 in size; Every one of the k pieces of each polyomino tile must align exactly with one of the chessboard squares. Your task is to figure out the maximum number of chessboard squares
tiled.
Input
There are multiple test cases in the input file.
First line contain the number of cases T (T≤10000).
In the next T lines contain T cases , Each case has two integers n and k. (1≤n,k≤100)
Output
Print the maximum number of chessboard squares tiled.
Sample Input
2 6 3 5 3
Sample Output
36 24
Source
BestCoder Round #17
用 k × 1 的小矩形覆盖一个 n × n 的正方形棋盘,问正方形棋盘最多能被覆盖多少。
规律就是:假设n<k。肯定不行。
定义mod=n%k;
假设(mod<=k/2),结果为:n*n-mod*mod;
否则结果为:n*n-(k-mod)*(k-mod);
点此证明
//0MS 228K #include<stdio.h> int main() { int t,n,k; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&k); if(n<k){printf("0\n");continue;} int mod=n%k; if(mod<=k/2)printf("%d\n",n*n-mod*mod); else printf("%d\n",n*n-(k-mod)*(k-mod)); } return 0; }
相关文章推荐
- HDU 5100 Chessboard (用k×1的矩形覆盖n×n的正方形)(找规律)
- HDU 5100 Chessboard 用 k × 1 的矩形覆盖 n × n 的正方形棋盘
- URAL —— 1255 & HDU 5100——Chessboard ——————【数学规律】
- 算法总结:【线段树+扫描线】&矩形覆盖求面积/周长问题(HDU 1542/HDU 1828)
- HDU 1507 Uncle Tom's Inherited Land*(行列匹配||棋盘覆盖||黑白染色||奇偶匹配(1X2的矩形覆盖))
- hdu 5100 n*n棋盘放k*1长方条最多覆盖面积
- HDU-正方形棋盘覆盖问题
- hdu 5100 n*n棋盘放k*1长方条最多覆盖面积
- bestcoder#17 1001&&HDU 5100 Chessboard(数学)
- 正方形不是矩形" << 【OOD设计原则之里氏替换原则(LSP)--- 设计模式之禅读书笔记
- HDU-1255 覆盖的面积 覆盖的矩形面积并
- hdu 4419 矩形面积覆盖颜色
- java&nbsp;&nbsp;棋盘覆盖程序&nbsp;算法分析题目
- hdu 1505 && hdu1506 &&hdu 2830 && 2870 总结---------DP之状图选最大矩形
- hdu 1255 覆盖的面积 矩形D层以上重叠面积
- hdu1255 覆盖的面积 线段树+里离散化求矩形面积的交
- 用1 ×2 的瓷砖覆盖8 ×8 的地板,有多少种方式呢?
- hdu 4328 极大子矩形加正方形DP
- POJ 1151 & HDU 1542 Atlantis (矩形切割)
- 用1 ×2 的瓷砖覆盖8 ×8 的地板,有多少种方式呢?