http://acm.hdu.edu.cn/showproblem.php?pid=5100
用1*k方格覆盖n*n方格
有趣的一道题,查了下发现m67的博客还说过这个问题
其实就是两种摆法取个最大值
1、横着摆放竖着补全,形成边长n%k的正方形
2、在一个角摆成风车形(边长k+n%k),中间形成边长为k-n%k的正方形
http://www.matrix67.com/blog/archives/5900
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map> using namespace std; int main(){
int T;
scanf("%d",&T);
while(T--){
int n,k;
scanf("%d%d",&n,&k);
if(n<k)printf("0\n");
else if(n%k==)printf("%d\n",n*n);
else printf("%d\n",n*n-min((n%k)*(n%k),(k-n%k)*(k-n%k)));
}
return ;
}