HDOJ 5100 Chessboard Structure

Source: Internet
Author: User

MATRIX67 Great god: http://www.matrix67.com/blog/archives/5900


ChessboardTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 538 Accepted Submission (s): 241


Problem Descriptionconsider The problem of tiling an nxn chessboard by polyomino pieces that is kx1 in size; Every one of the k pieces of each polyomino tiles must align exactly with one of the chessboard squares. Your task is to figure out the maximum number of chessboard squares tiled.
Inputthere is 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 both integers n and K. ( 1≤n,k≤ )
Outputprint the maximum number of chessboard squares tiled.
Sample Input
26 35 3

Sample Output
3624

Sourcebestcoder Round #17




#include <iostream> #include <cstring> #include <cstdio> #include <algorithm>using namespace Std;int Main () {int t_t;int n,k;scanf ("%d", &t_t), while (t_t--) {scanf ("%d%d", &n,&k), if (k>n) {puts ("0") ; continue;} int r=n%k;if (R>K/2) r=k-r;printf ("%d\n", N*n-r*r);} return 0;}


HDOJ 5100 Chessboard Structure

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.