hdu4671 Backup Plan ——构造题
link:http://acm.hdu.edu.cn/showproblem.php?pid=4671
其实是不难的那种构造题,先排第一列,第二列从后往前选。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <queue>
#include <deque>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <functional>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <cassert>
#include <ctime>
#include <iterator>
const int INF = 0x3f3f3f3f;
const int dir[][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
using namespace std;
int sad[], fun[][];
int main(void)
{
int n, m;
while (~scanf("%d%d",&n,&m))
{
for(int i=;i<=n;++i)
{
sad[i]=m/n;
if(i<=m%n) sad[i]++;
}
int row=;
for(int i=;i<=n;++i)
{
int k=n;
for(int j=;j<=sad[i];++j)
{
while (i==k||k==)
{if(i==k) k--;
if(k==) k=n;}
fun[row][]=i;
fun[row][]=k;
k--; row++;
}
}
for(int i=;i<=m;++i)
{
printf("%d %d",fun[i][],fun[i][]);
for(int j=;j<=n;++j)
{
if(j!=fun[i][]&&j!=fun[i][]) printf(" %d",j);
}
printf("\n");
}
}
return ;
}
代码写的很清楚,不行模拟一下什么就懂了。
hdu4671 Backup Plan ——构造题的更多相关文章
- HDU-4671 Backup Plan 构造解
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4671 假设是3 m,首先按照第一列按照1 2 3 1 2 3 1...排下去,然后个数就是一个 (m/ ...
- HDU 4671 Backup Plan 构造
负载是否平衡只与前两列有关,剩下的只要与前两列不重复就随便放. 第一列我们按1-n这样循环放,第二列每次找个数最少的那个服务器放. #include <cstdio> #include & ...
- HDU 4671 Backup Plan (2013多校7 1006题 构造)
Backup Plan Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
- cf251.2.C (构造题的技巧)
C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...
- Educational Codeforces Round 7 D. Optimal Number Permutation 构造题
D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...
- Codeforces 482 - Diverse Permutation 构造题
这是一道蛮基础的构造题. - k +(k - 1) -(k - 2) 1 + k , 1 , k , 2, ....... ...
- BZOJ 3097: Hash Killer I【构造题,思维题】
3097: Hash Killer I Time Limit: 5 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 963 Solved: 36 ...
- CF1110E Magic Stones(构造题)
这场CF怎么这么多构造题…… 题目链接:CF原网 洛谷 题目大意:给定两个长度为 $n$ 的序列 $c$ 和 $t$.每次我们可以对 $c_i(2\le i<n)$ 进行一次操作,也就是把 $c ...
- Create maintenance backup plan in SQL Server 2008 R2 using the wizard
You will need to identify how you want your maintenance plan to be setup. In this example the mainte ...
随机推荐
- 反编译CHM文件
1.进入dos 2.输入 HH.EXE -decompile <输出路径> <目标chm文件> 例如:hh.exe -decompile d:\heihei D:\123.ch ...
- Response.BinaryWrite()方法输出二进制图像
protected void Page_Load(object sender, EventArgs e) { FileStream fs = new FileStream(Server.MapPath ...
- 让IE7 IE8支持CSS3 background-size属性
简介 CSS3 新增的 background-size 是一个很有用的属性,用于定义背景图片的尺寸,有了这个属性,你就可以任意指定背景图片的大小.其中最常用的值应该要数 cover 了,该值能让背景图 ...
- ExceptionExtensions
public static class ExceptionExtensions { public static IEnumerable<Exception> GetAllException ...
- webform简单控件
表单元素: 文本类: text password textarea hidden text,password,textarea实现控件:textbox textmode属性选择password或m ...
- Windows 数据类型
类型 定义 描述 ATOM typedef WORD ATOM; 原子(原子表中的一个字符串的参考) BOOL typedef int BOOL; 布尔变量 BOOLEAN typedef BYTE ...
- FTPS链接服务器
一.首先登录ftp服务器:命令行 lftp user@ip 上传:put 下载: get 二. 关于FTP传输模式与传输的方式 众所周知,FTP传输有两种工作模式,Active Mode和Pass ...
- Android Studio - HPROF文件查看和分析工具
Android Studio 翻译的官方文章 原文链接 当你在Android Studio中使用Android Monitor里的Memory Monitor工具监视内存使用情况时,可以把Java堆快 ...
- 能源项目xml文件 -- springMVC-servlet.xml -- context:component-scan
<context:component-scan base-package="com.xindatai.ibs" use-default-filters="false ...
- 初识python中的类与对象
这篇博客的路线是由深入浅,所以尽管图画的花花绿绿的很好看,但是请先关注我的文字,因为初接触类的小伙伴直接看类的实现可能会觉得难度大,只要耐着性子看下去,就会有一种“拨开迷雾看未来”的感觉了. 一.py ...