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. AFNetworking(AFN)总结

    AFNetworking(AFN) ----主要做下载上传之用 //他是干啥的?发送请求,主要做下载上传之用 (苹果自带有获取服务器数据的方法NSURLConnection send,AFNetwor ...

  2. nyoj1007(euler 函数)

    euler(x)公式能计算小于等于x的并且和x互质的数的个数: 我们再看一下如何求小于等于n的和n互质的数的和, 我们用sum(n)表示: 若gcd(x, a)=1,则有gcd(x, x-a)=1: ...

  3. sql server 常用脚本(日常查询所需)

    1:查看sql server代理中作业的运行状况的脚本 -- descr : a simple sql script to view sql server jobs run status -- las ...

  4. C/C++学习笔记---高地址、低地址、大段字节序、小段字节序

    字节顺序是指占内存多于一个字节类型的数据在内存中的存放顺序,通常有小端.大端两种字节顺序. 小端字节序指低字节数据存放在内存低地址处,高字节数据存放在内存高地址处: 大端字节序是高字节数据存放在低地址 ...

  5. C# 面试宝典

    1.简述 private. protected. public. internal 修饰符的访问权限. private  私有成员 只有类成员才能访问 protected  保护成员 只有该类及该类的 ...

  6. Delphi按下F1不能出现帮助文档的解决方法

    不光是Delphi,Windows里面所有的之所以无法打开.hlp帮助文档的问题都可以使用以下的方法来解决 问题:情况是这样的,不是打不开hlp帮助文档,按F1出现的是Windows的帮助.而Delp ...

  7. Ajax 的 GET 和 POST 模式

    Ajax 异步请求数据的方式有两种:GET 和 POST. 如果是 GET 模式,则直接将数据放置到异步请求的 URL 地址中,而 send() 方法不发送任何数据: var queryString ...

  8. play-framework的安装与使用

    一.下载: 到http://www.playframework.com/download下载 解压好包,然后输入: activator ui 访问:http://127.0.0.1:8888/home

  9. fis3-postpackager-loader插件说明

    fis3-postpackager-loader 静态资源前端加载器,用来分析页面中使用的和依赖的资源(js或css), 并将这些资源做一定的优化后插入页面中.如把零散的文件合并. 注意 此插件做前端 ...

  10. css 全局 兼容性问题

    css 笔记 第一种:常用的全局CSS属性设置 //参考大型网站,如凤凰网 (1)清除所有的标记的内外边距 body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,p ...