Chessboard

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 910    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)
 
Output
Print the maximum number of chessboard squares tiled.
 
Sample Input
2
6 3
5 3
 
Sample Output
36
24
 
Source

我去你妹的数学题,真坑
#include<cstdio>
#include<cstring>
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,k;
scanf("%d%d",&n,&k);
if(k>n)
printf("0\n");
else
{
int num=n%k;
if(num>k/2)
num-=k;
printf("%d\n",n*n-num*num);
}
}
return 0;
}

 

hdoj--5100--Chessboard(数学推理)的更多相关文章

  1. URAL —— 1255 & HDU 5100——Chessboard ——————【数学规律】

    用 k × 1 的矩形覆盖 n × n 的正方形棋盘 用 k × 1 的小矩形覆盖一个 n × n 的正方形棋盘,往往不能实现完全覆盖(比如,有时候 n × n 甚至根本就不是 k 的整倍数). 解题 ...

  2. HDU 5100 Chessboard 用 k &#215; 1 的矩形覆盖 n &#215; n 的正方形棋盘

    pid=5100">点击打开链接 Chessboard Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32 ...

  3. hdu 5100 Chessboard

    http://acm.hdu.edu.cn/showproblem.php?pid=5100 在比赛时没看懂题就没看,结束之后,看了解题报告才知道怎么做. 解题报告: 首先,若n<k,则棋盘连一 ...

  4. nyist 303序号互换(数学推理)

    题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=303 思路: 开始看错题了,以为最多只有两个字母. 字母转数字的表达式很容易看出来是:(2 ...

  5. hdu 5626 Clarke and points 数学推理

    Clarke and points Problem Description   The Manhattan Distance between point A(XA,YA) and B(XB,YB) i ...

  6. HDOJ 5073 Galaxy 数学 贪心

    贪心: 保存连续的n-k个数,求最小的一段方差... .预处理O1算期望. .. Galaxy Time Limit: 2000/1000 MS (Java/Others)    Memory Lim ...

  7. 【HDOJ 1085】数学问题,母函数

    Holding Bin-Laden Captive! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...

  8. BZOJ1192 [HNOI2006]鬼谷子的钱袋 数学推理

    欢迎访问~原文出处——博客园-zhouzhendong 去博客园看该题解 题目传送门 - BZOJ1192 题意概括 把一个数m拆成很多数字. 问至少拆成多少个数字,1~m中的所有数字才可以用这些数字 ...

  9. HDU2552 三足鼎立 【数学推理】

    三足鼎立 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submi ...

随机推荐

  1. html5——伸缩比例案例(携程)

    1.有图片的盒子,最好是父盒子设置伸缩属性,a标签设置伸缩比例1,img标签宽度100% 2.不要见到父盒子就设置伸缩属性,而是根据子盒子是否占据一行,若是子盒子占据一行,那么只要给子盒子设置伸缩比例 ...

  2. [Windows Server 2012] WordPress安全设置方法

    ★ 欢迎来到[护卫神·V课堂],网站地址:http://v.huweishen.com ★ 护卫神·V课堂 是护卫神旗下专业提供服务器教学视频的网站,每周更新视频. ★ 本节我们将带领大家:WordP ...

  3. Python语言之变量1(数值,字符串,布尔)

    1.数值 整数:2, -2 长整数:2**1024, 2**2048(真的可以很~长~~~,手残算了个2**100000,IDLE还真给打出来了,ORZ) 浮点数:7.05, 1E2(100.0), ...

  4. python socket 接口

    一.简介 socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字"向网络发出请求或者应答网络请求.socket起 ...

  5. C语言数据结构链栈(创建、入栈、出栈、取栈顶元素、遍历链栈中的元素)

    /**创建链栈*创建一个top指针代表head指针*采用链式存储结构*采用头插法创建链表*操作 创建 出栈 入栈 取栈顶元素*创建数据域的结构体*创建数据域的名称指针*使用随机函数对数据域的编号进行赋 ...

  6. EF-Linq

    一丶基本语法(from a in Table where a.id="001" select a).Tolist(); 隐式内连接from a in table1 join b i ...

  7. Centos7下mysql的主从配置

    最近,有朋友业务并发量比较大,让我帮他配置个主从,来缓解数据库的压力.下面就是我配置的,有需要的朋友可以借鉴下. 首先,我得到2台服务器: 172.18.2.142(主) 172.18.2.141(从 ...

  8. time模块和datatime模块

    一.time模块 time.time() 获取时间戳 time.sleep() 睡几秒 time.gmtime() utc时间元组 time.localtime() 本地时间元组 time.mktim ...

  9. PAT 1103 Integer Factorization

    The K-P factorization of a positive integer N is to write N as the sum of the P-th power of K positi ...

  10. PAT 1057. Stack

    Stack is one of the most fundamental data structures, which is based on the principle of Last In Fir ...