HDOJ 5100 Chessboard【规律】
来源:互联网 发布:免流源码 编辑:程序博客网 时间:2024/05/18 00:06
Chessboard
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 911 Accepted Submission(s): 384
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 )
First line contain the number of cases T (
In the next T lines contain T cases , Each case has two integers n and k. (
Output
Print the maximum number of chessboard squares tiled.
Sample Input
26 35 3
Sample Output
3624
#include <iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ int t,n,k,s; scanf("%d",&t); while(t--) { scanf("%d%d",&n,&k); if(n<k) { printf("0\n"); continue; } s=n*n; int tem=n%k; if(tem) { int cnt1=tem*tem; int tt=k-tem; int cnt2=tt*tt; //printf("%d %d\n",cnt1,cnt2); s=s-min(cnt1,cnt2); } printf("%d\n",s); } return 0;}
0 0
- HDOJ 5100 Chessboard【规律】
- hdoj 5100 Chessboard (思维规律)
- hdoj Chessboard 5100 (数学几何规律)
- HDOJ 5100 Chessboard 构造
- hdoj 5100 Chessboard 【思维】
- hdoj 5100 Chessboard
- HDOJ 题目5100 Chessboard(数学乱搞)
- hdoj--5100--Chessboard(数学推理)
- HDOJ 5100 Chessboard (骨牌覆盖问题)
- LightOJ1010---Knights in Chessboard (规律题)
- light1010 - Knights in Chessboard【找规律】
- 1010 - Knights in Chessboard(找规律)
- lightoj 1010-Knights in Chessboard (规律)
- LightOJ-1010-Knights in Chessboard [规律]
- lightoj1010 Knights in Chessboard(找规律)
- hdoj-2709-Sumsets【规律】
- HDOJ 1703 PBD (规律)
- hdoj 5344 找规律
- c语言面试题2
- HDU 2149 Public Sale
- 国内代码托管git-osc基础使用教程
- leetcode:Pascal's Triangle II 【Java】
- 运维自动化架构
- HDOJ 5100 Chessboard【规律】
- 概念的解释(二)
- Linux学习笔记
- css-照片瀑布流显示
- 关于字符串参数传递的小技巧
- Arking advices | WPI
- Quartz2D - 画饼图
- 自定义组合控件,组合模式
- Contains Duplicate