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 ...
随机推荐
- maven环境快速搭建
----------------准备工作------------- Jdk 1.5以上java开发环境. Eclipse IDE 一个. Maven 3.0.3下载地址: http://maven. ...
- webform简单控件
表单元素: 文本类: text password textarea hidden text,password,textarea实现控件:textbox textmode属性选择password或m ...
- oracle 之 游标
本期主题 灰蓝 游标用来处理从数据库中检索的多行记录(使用SELECT语句)存放的是select 的结果 利用游标,程序可以逐个地处理和遍历一次检索返回的整个记录集 --隐式游标 begin upd ...
- 启动tomcat后struts框架报异常严重: Exception starting filter struts2 Unable to load configuration.
启动tomcat后struts框架报异常严重: Exception starting filter struts2 Unable to load configuration. 出现此异常是因为,str ...
- 如何正确的将J2ee项目部署到Tomcat
如何正确的将J2ee项目部署到Tomcat 1.打开配置文件(我的如下:C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\serv ...
- Security » Authorization » 基于声明的授权
Claims-Based Authorization¶ 基于声明的授权 142 of 162 people found this helpful When an identity is created ...
- Yii2框架安装(windows)
-->安装PHP环境Wamp集成环境,XAMMP等.-->安装Composerhttp://pan.baidu.com/s/1i3fejjvPS:安装过程中的有一个手动操作项选择php.e ...
- PDF 补丁丁 0.4.3.1342 测试版发布:修复崩溃问题
PDF 补丁丁 0.4.3.1342 测试版发布了. 此测试版修复了之前测试版在合并文件.书签编辑器.文档结构探查器中出现的崩溃问题. 推荐下载了0.4.3测试版的网友尽快更新.
- Launch Screen在iOS7/8中的实现
Launch Screen在iOS7/8中的实现 目前项目中需要解决的问题是: 兼容iOS7和iOS8,之前的版本不需要支持了 实现兼容3.5.4.4.7和5.5寸屏幕,竖屏的Lauch Screen ...
- 找做IT的男朋友会不会没有隐私
找做IT的男朋友会不会没有隐私你不觉得自己在网上不断的“秀”啊,“晒”啊的行为才是根本所在吗?你应该怕自己的这种行为才对吧-—————————————————————————————————————— ...