1641. Duties
枚举
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<vector>
using namespace std;
int w[][],o[];
int main()
{
int i,j,k,n,m;
scanf("%d%d%d",&n,&k,&m);
int t = ;
for(i = ; i <= n ; i++)
{
if(t>k)
t = ;
o[i] = t;
printf("%d\n",t);
t++;
}
int tt=,a=;
while()
{
if(a<=n)
{
if(a<n)
{
printf("%d %d\n",a,a+);
w[a][a+] = ;
w[a+][a] = ;
a+=;
}
else
{
printf("%d %d\n",n-,n);
w[n-][n] =;
w[n][n-] = ;
a++;
}
tt++;
}
else
{
for(i = ; i <= n ;i++)
{
for(j = ; j <= n ; j++)
if(i!=j&&!w[i][j]&&o[i]!=o[j])
{
printf("%d %d\n",i,j);
w[i][j] = ;
w[j][i] = ;
tt++;
if(tt==m)
break;
}
if(tt==m)
break;
}
}
if(tt==m)
break;
}
return ;
}
1641. Duties的更多相关文章
- NOJ 1641 错误的算法(模拟)
[1641] 错误的算法 时间限制: 5000 ms 内存限制: 65535 K 问题描述 有道题目是这样的: 输入一个 n 行 m 列网格,找一个格子,使得它所在的行和列中所有格子的数之和最大.如果 ...
- BZOJ 1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏( floyd )
直接floyd.. ---------------------------------------------------------------------------- #include<c ...
- 1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏
1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 424 Solved: 272 ...
- 一本通1641【例 1】矩阵 A×B
1641: [例 1]矩阵 A×B sol:矩阵乘法模板.三个for循环 #include <bits/stdc++.h> using namespace std; typedef lon ...
- SUST OJ 1641: 电子狗的心事
1641: 电子狗的心事 时间限制: 1 Sec 内存限制: 128 MB提交: 192 解决: 14[提交][状态][讨论版] 题目描述 计算机程序世界中有一位孤独的电子狗,这个电子狗每次只能执 ...
- 【BZOJ】1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏(floyd)
http://www.lydsy.com/JudgeOnline/problem.php?id=1641 这种水题无意义... #include <cstdio> #include < ...
- BZOJ 1641 [Usaco2007 Nov]Cow Hurdles 奶牛跨栏:新版floyd【路径上最大边最小】
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1641 题意: 给你一个有向图,n个点(n <= 300),m条边,边权为h[i]. ...
- UVa 1641 ASCII Area
题意: 就是用一个字符矩阵代表一个闭合的阴影部分,然后求阴影部分的面积. 分析: 一个'/'和'\'字符都代表半个小方块的面积. 关键就是判断'.'是否属于阴影部分,这才是本题的关键. 从第一列开始, ...
- BZOJ 1641: [Usaco2007 Nov]Cow Hurdles 奶牛跨栏
Description Farmer John 想让她的奶牛准备郡级跳跃比赛,贝茜和她的伙伴们正在练习跨栏.她们很累,所以她们想消耗最少的能量来跨栏. 显然,对于一头奶牛跳过几个矮栏是很容易的,但是高 ...
随机推荐
- getHeight returns 0 for all Android UI objects
It's 0 because in both onCreate and onStart, the view hasn't actually been drawn yet. You can get ar ...
- DevExpress控件使用系列--ASPxTreeList
控件功能 结合列表控件及树控件的优点,在列表控件中实现类型树的多层级操作 官方说明 http://documentation.devexpress.com/#AspNet/clsDevExpres ...
- ubuntu 安装git
问题描述: ubuntu安装git 问题解决: (1)ubuntu下载git 注: 使用命令apt-get install git安装 (2)查看g ...
- Html特殊字符转义处理
#region 将Html特殊字符转义处理 /// <summary> /// 将Html特殊字符转义处理 /// </summary> ...
- memmove和memcpy 以及strcmp strcpy几个库函数的实现
memmove和memcpy 1.memmove 函数原型:void *memmove(void *dest, const void *source, size_t count) 返回值说明:返回指向 ...
- PSYoungGen /PSOldGen/PSPermGen区别
原文地址:http://bbs.csdn.net/topics/210064791 谁能解译一下PSYoungGen /PSOldGen/PSPermGen区别及出现的问题? 看来没有收集到答案,查看 ...
- lintcode :Trailing Zeros 尾部的零
题目: 尾部的零 设计一个算法,计算出n阶乘中尾部零的个数 样例 11! = 39916800,因此应该返回 2 挑战 O(logN)的时间复杂度 解题: 常用方法: 也许你在编程之美中看到,通过求能 ...
- python url编码,解码
>>> urllib.unquote('%E4%B8%BD%E6%B1%9F') >>> data '\xe4\xb8\xbd\xe6\xb1\x9f' >& ...
- 248. Strobogrammatic Number III
题目: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at ups ...
- 内存单元按字节编址,地址0000A000H~0000BFFFH共有几个存储单元
一般可以这样:按十六进制(bffff-a000)+1=1fff+12000H=2x16x16x16=81928192/1024=8 最后是8k或者按二进制bfff-a000=0001 1111 111 ...