YT14-HDU-棋盘与骨牌块
来源:互联网 发布:网络车管所 编辑:程序博客网 时间:2024/04/27 04:03
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 \leq 10000$).
In the next T lines contain T cases , Each case has two integers n and k. ($1 \leq n, k \leq 100$)
First line contain the number of cases T ($T \leq 10000$).
In the next T lines contain T cases , Each case has two integers n and k. ($1 \leq n, k \leq 100$)
Output
Print the maximum number of chessboard squares tiled.
Sample Input
26 35 3
Sample Output
3624
#include<iostream>using namespace std;int main(){ int t; cin>>t; while(t--) { int n,k,m; cin>>n>>k; if(n<k) { cout<<"0"<<endl; continue; } m=n%k; if(m>k/2) cout<<n*n-(k-m)*(k-m)<<endl; else cout<<n*n-m*m<<endl; } return 0;}
运行结果:
0 0
- YT14-HDU-棋盘与骨牌块
- YT14-HDU-盒子与瓷砖
- YT14-HDU-S与D的故事
- YT14-HDU-#是@与.爱情的那堵墙
- YT14-HDU-James跳桥
- YT14-HDU-圆桌会议
- YT14-HDU-取余
- YT14-HDU-求多组数的最小公倍数
- YT14-HDU-中国剩余定理
- YT14-HDU-洗牌的规律
- YT14-HDU-叠加的卡片
- YT14-HDU-Eddy的彩票
- YT14-HDU-找新朋友
- YT14-HDU-机器人走表格
- YT14-HDU-油井的种类
- YT14-HDU-命中注定的另一半
- L型骨牌棋盘覆盖
- YT14-HDU-求抛物线与直线间的面积(积分)
- [算法系列之九]Karatsuba快速相乘算法
- PHP官方Windows扩展列表
- 自定义日期
- hdu2126——Buy the souvenirs——————【01背包记录物品最多时种数】
- 加载依赖的jar包在命令行编译和运行java文件
- YT14-HDU-棋盘与骨牌块
- 2010山东ACM省赛 Hello World! Sdut2158
- Cocos2d-x3.3Final(4) ImageView常用成员函数(C++)
- oracle分页查询
- eclipse使用技巧1——工作空间导入配置文件
- Vector< Vector<Point> >
- hdu 2113 Secret Number (水题)
- C++ 虚函数表解析
- solr 4.0 与php结合SolrPhpClient实现