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 ——构造题的更多相关文章

  1. HDU-4671 Backup Plan 构造解

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4671 假设是3 m,首先按照第一列按照1 2 3 1 2 3 1...排下去,然后个数就是一个 (m/ ...

  2. HDU 4671 Backup Plan 构造

    负载是否平衡只与前两列有关,剩下的只要与前两列不重复就随便放. 第一列我们按1-n这样循环放,第二列每次找个数最少的那个服务器放. #include <cstdio> #include & ...

  3. HDU 4671 Backup Plan (2013多校7 1006题 构造)

    Backup Plan Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Total ...

  4. cf251.2.C (构造题的技巧)

    C. Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabyt ...

  5. Educational Codeforces Round 7 D. Optimal Number Permutation 构造题

    D. Optimal Number Permutation 题目连接: http://www.codeforces.com/contest/622/problem/D Description You ...

  6. Codeforces 482 - Diverse Permutation 构造题

    这是一道蛮基础的构造题. - k         +(k - 1)      -(k - 2) 1 + k ,    1 ,         k ,             2,    ....... ...

  7. BZOJ 3097: Hash Killer I【构造题,思维题】

    3097: Hash Killer I Time Limit: 5 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 963  Solved: 36 ...

  8. CF1110E Magic Stones(构造题)

    这场CF怎么这么多构造题…… 题目链接:CF原网 洛谷 题目大意:给定两个长度为 $n$ 的序列 $c$ 和 $t$.每次我们可以对 $c_i(2\le i<n)$ 进行一次操作,也就是把 $c ...

  9. 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 ...

随机推荐

  1. mmap()与munmap()的小例子

    mmap() 和 munmap() - Unix的系统函数,更贴近底层 void* mmap(void* addr,size_t size,int prot,int flags, int fd, of ...

  2. git的一些常用方法

    1.撤销add但未commit的文件: git rm -r --cached path/file 2.git 撤销commit: 2.1).git log-显示提交的历史 commit ee50348 ...

  3. iOS - Apache Tomcat WebServer 服务器配置

    前言 提前下载好相关软件,且安装目录最好安装在全英文路径下.如果路径有中文名,那么可能会出现一些莫名其妙的问题. 提前准备好的软件: apache-tomcat-6.0.45.tar.gz eclip ...

  4. Centos系统下Lamp环境的快速搭建(超详细,转)

    lamp的搭建对于初学者是一件很头疼的事情,所以借此机会把自己当初快速搭建linux+apche+mysql+php的方法分享大家希望能到你. 工具/原料 虚拟机及Centos操作系统 Linux基本 ...

  5. 内部类 & 泛型

    内部类 主要作用 1. 内部类, 主要用于事件监听的方法实现.2. 用于多继承 注: 主要还是 1 用的比较多. 参考 : head first java (第12章) 泛型 head first j ...

  6. Linux nginx日志按天分割实例

    Linux nginx日志按天分割实例   nginx的日志有个小缺点,日志文件一直就是一个,不会自动地进行切割,如果访问量很大的话,将导致日志文件非常大,不便于管理这就需要我们自己来实现了,按日期每 ...

  7. ABAP之PINYING拼音

    前面说了声母韵母,那么现在来说说ABAP里的拼音——域,数据元素,结构 PINGGUO = 苹果 T-CODE : SE11   如下图 域:是一些特定值的集合,或者某一种特殊用途的集合.如:需要定义 ...

  8. 线性布局通过适配器可以动态加载view

    因为适配器的getView的返回对象是view, 所以线性布局的对象可以通过addView动态加载适配器的getView 举例: mTestAdapter = new ListAdapter(this ...

  9. [转]CSS网页布局:div水平居中的各种方法

    http://jingyan.baidu.com/article/fa4125ac90a2a328ac70929e.html 在Web标准中的页面布局是使用Div配合CSS来实现的.这其中最常用到的就 ...

  10. iOS开发网络篇—HTTP协议

    iOS开发网络篇—HTTP协议 说明:apache tomcat服务器必须占用8080端口 一.URL 1.基本介绍 URL的全称是Uniform Resource Locator(统一资源定位符) ...