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. LTE Module User Documentation(翻译13)——频率复用算法(Frequency Reuse Algorithms)

    LTE用户文档 (如有不当的地方,欢迎指正!)   19 Frequency Reuse Algorithms(频率复用算法)   本节我们将描述如何在 LTE 仿真中使用频率复用(FR)算法.共有两 ...

  2. 在腾讯云上创建您的SQL Cluster(4)

    版权声明:本文由李斯达原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/255 来源:腾云阁 https://www.qclo ...

  3. C#日常总结1

    Rows:行的集合: Columns:列的集合: Gridview:用来显示数据的表格{ //设置 AutoGenerateColumns="false":表示不允许自动产生列,列 ...

  4. Selenium WebDriver中一些鼠标和键盘事件的使用

    转自:http://www.ithov.com/linux/133271.shtml 在使用 Selenium WebDriver 做自动化测试的时候,会经常模拟鼠标和键盘的一些行为.比如使用鼠标单击 ...

  5. js输入,输出基本操作

  6. tiny_cnn代码阅读(2)

    上一篇讲了mse函数 , 这次gradient_descent_levenberg_marquardt @see ${root}/tiny_cnn/optimizer/optimizer.h 这个函数 ...

  7. VUE应用的一些感受

    方便,数据绑定太方便了. 一个组件一个.vue文件特别清晰. 讲真vue比angular好学多了. webpack打包最近看懂,通过一个主文件把require的文件都打进来.业务代码放build里,引 ...

  8. 坑爹的属性,android:descendantFocusability用法简析

    开发中很常见的一个问题,项目中的listview不仅仅是简单的文字,常常需要自己定义listview,自己的Adapter去继承 BaseAdapter,在adapter中按照需求进行编写,问题就出现 ...

  9. MVC5 + EF6 入门完整教程二:从前端的UI开始

    从前端的UI开始 MVC分离的比较好,开发顺序没有特别要求,先开发哪一部分都可以,这次我们主要讲解前端UI的部分. ASP.NET MVC抛弃了WebForm的一些特有的习惯,例如服务器端控件,Vie ...

  10. ios基础篇(十一)——UINavgationController的使用(二)页面切换

    上篇说到了添加UIBarButtonItem,接下来说说界面切换: 1.首先我们在刚才的RootViewController中添加一个按钮用来实现跳转: 打开RootViewController.m( ...