1255. Graveyard of the Cosa Nostra

Time limit: 1.0 second
Memory limit: 64 MB
There is a custom among the Ural Mafiosi — a big Mafioso’s coffin is to be carried by all his subordinates. The length of the coffin (in meters) equals to the number of the Mafioso’s subordinates in order not to let the carriers to encumber each other. As it happens, according to the ancient custom the width of a coffin is equal to 1 meter. So, the length of a coffin shows a dead man’s authority. By the way, the Ural Mafiosi are very scrupulous in matters of authority and will not bear neighborhood with less authoritative Mafioso. So, at one cemetery it’s possible to bury Mafiosi with equal authority. According to the Mafiosi’s custom a cemetery must be square. A cemetery length must be an integer number of meters.
You are to count how many Mafiosi can be buried on the cemetery of the given size. Coffins must be parallel to cemetery borders, coffins mustn’t overlap each other and get off the cemetery.

Input

Contains two numbers — a length of the cemetery N (1 < N < 10000) and a length of a coffin K (1 < K< 10000).

Output

The single integer number — the most amount of the coffins of the size 1×K that may be buried at the cemetery of the size N×N.

Sample

input output
5 4
6
Problem Author: Stanislav Vasilyev, Alexey Lakhtin
Problem Source: Open collegiate programming contest for student teams, Ural State University, March 15, 2003
Difficulty: 267
 
题意:给出n,k问一个n*n的正方形,最多可以塞下多少1*k的小矩阵。
分析:比较经典的问题。
献给正方形染色,
1 2 3 ...... k 1 2 ....... k 1 ..... n%k
2 3 4 ....k 1 2 3 .....k 1 2 ....
这样染色。
可以保证每放下一个矩阵,都会覆盖到1..k的颜色各一次。
显然答案是颜色的最小个数。
也就是,问题转变成了求染色后的正方形颜色个数最小是多少。
证明我也不会,但看上去就是对的。。。。。
所以按照这个思路就可以求了。
 
 /**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} int n, k; inline void Input()
{
cin >> n >> k;
} inline void Solve()
{
if(n < k) cout << << endl;
else cout << ((n / k) * n) + ((n % k) * (n / k)) + max( * (n % k) - k, ) << endl;
} int main()
{
freopen("a.in", "r", stdin);
Input();
Solve();
return ;
}

ural 1255. Graveyard of the Cosa Nostra的更多相关文章

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

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

  2. 100-days: thirteen

     Title: “The Godfather turns 50” <教父>50周年 turn 达到某个年龄 Mario Puzo's(马里奥·普佐) "The Godfather ...

  3. leggere la nostra recensione del primo e del secondo

    La terra di mezzo in trail running sembra essere distorto leggermente massima di recente, e gli aggi ...

  4. hdu 1255

    覆盖的面积 Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Sub ...

  5. POJ3154 Graveyard

    Graveyard Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 1654   Accepted: 840   Specia ...

  6. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  7. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  8. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  9. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

随机推荐

  1. 数的统计count(bzoj1036)

    Description 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w.我们将以下面的形式来要求你对这棵树完成一些操作: I. CHANGE u t : 把结点u的权值改为t II. Q ...

  2. EF增删改查基础

    #region 1.0 新增 -void Add() /// <summary> /// 1.0 新增 /// </summary> static void Add() { / ...

  3. EventBus学习入门

    EventBus Features What makes greenrobot's EventBus unique, are its features: Simple yet powerful: Ev ...

  4. php导出excel封装类

    因为实际情况的需要,导出excel表格在后台开发的过程中会经常用到.下面是我在实际应用中自己整理的一个导出excel类,需要PHPExcel支持,本类很好的完成导出表格的基本样式,保存路径,切换工作薄 ...

  5. windows服务 2.实时刷新App.config

    参考 http://www.cnblogs.com/jeffwongishandsome/archive/2011/04/24/2026381.html http://www.cnblogs.com/ ...

  6. Android Matrix

    转自 :http://www.cnblogs.com/qiengo/archive/2012/06/30/2570874.html#code Matrix的数学原理 平移变换 旋转变换 缩放变换 错切 ...

  7. [LeetCode] Word Pattern

    Word Pattern Total Accepted: 4627 Total Submissions: 17361 Difficulty: Easy Given a pattern and a st ...

  8. 证明tmult_ok的正确性

    csapp page124. practice problem 2.35 /* Determine whether arguments can be multiplied without overfl ...

  9. hibernate中many-to-one关联时出现ObjectNotFoundException异常

    采用多对一关联,如果一的那端删除了,多的这端无法感知,虽然数据库中可以通过外键配置将多的一端置空,可是在hibernate里面我暂时不知道如何处理. 目前采用的方式: 1.首先,数据库中需要配置好外键 ...

  10. 3-1创建Sql Sever数据库登录名

    登录名:连接Sql Sever 服务器 数据库用户名: Sql Sever 的使用者 每个用来登录Sql Sever 的账户都是一个用户. 同一个数据库可以拥有多个用户,每一个用户也同时可以访问多个数 ...