SDUT3143:Combinatorial mathematics(组合数学)
题意:传送门
题目描述
输入
输出
示例输入
3 2
3 1
示例输出
Case #1:
1 2
1 3
2 3 Case #2:
1
2
3
题目很简单,代码很快就敲出来了,令人伤心的是PE无数遍,因为之前的题都没卡那么严,遇到这种输出格式错误慌了.......
每组数据之后有一个空行,但是最后一组数据没有空行,如果只输入一组n,m,那么之后不需要打印空行。
具体请看代码:
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <stack>
#define inf 0x3f3f3f3f
#include <stdio.h>
#include <string.h>
typedef long long ll;
#define mod 10000007
#define eps 1e-9
using namespace std;
int n,r,a[];
void dfs(int k,int step)
{
a[step]=k;
if(step>r) return ;
if(step==r)
{
for(int i=; i<=step; i++)
{
if(i==) printf("%d",a[i]);
else printf(" %d",a[i]);
}
printf("\n");
}
for(int i=k+; i<=n; i++)
dfs(i,step+);
}
int main()
{
int K=;
while(scanf("%d%d",&n,&r)!=EOF)
{
if(K>=1) printf("\n");//这样能避免PE
printf("Case #%d:\n",++K);
for(int i=; i<=n-r+; i++)
dfs(i,);
}
return ;
}
SDUT3143:Combinatorial mathematics(组合数学)的更多相关文章
- [LeetCode] Find the Derangement of An Array 找数组的错排
In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no ...
- 【转】科大校长给数学系学弟学妹的忠告&本科数学参考书
1.老老实实把课本上的题目做完.其实说科大的课本难,我以为这话不完整.科大的教材,就数学系而言还是讲得挺清楚的,难的是后面的习题.事实上做1道难题的收获是做10道简单题所不能比的. 2.每门数学必修课 ...
- slot游戏中的数学概念
最近研究slot 算法,看了大量的英文资料,因为母语中文,一直使用中文的英文小白来说,好心塞,悔不当初没学好英文. 下文是从众多的英文中摘录的唯一能够看明白的概念.先给自己留着,到时候深入研究可以看 ...
- SCI&EI 英文PAPER投稿经验【转】
英文投稿的一点经验[转载] From: http://chl033.woku.com/article/2893317.html 1. 首先一定要注意杂志的发表范围, 超出范围的千万别投,要不就是浪费时 ...
- 一位学长的ACM总结(感触颇深)
发信人: fennec (fennec), 信区: Algorithm 标 题: acm 总结 by fennec 发信站: 吉林大学牡丹园站 (Wed Dec 8 16:27:55 2004) AC ...
- [leetcode-634-Find the Derangement of An Array]
In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no ...
- Something-Summary
1.Combinatorial Mathematics 1.1 Bell Number: \(B_n\)表示元素个数为n的集合划分成若干个不相交集合的方案数. \(B_{n + 1} = \sum_{ ...
- 德布鲁因序列与indexing 1
目录 写在前面 标记left-most 1与right-most 1 确定位置 德布鲁因序列(De Bruijn sequence) 德布鲁因序列的使用 德布鲁因序列的生成与索引表的构建 参考 博客: ...
- What Is Mathematics?
What Is Mathematics? The National Council of Teachers of Mathematics (NCTM), the world's largest org ...
随机推荐
- 数据库 proc编程三
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <stri ...
- Hadoop中HDFS工作原理
转自:http://blog.csdn.net/sdlyjzh/article/details/28876385 Hadoop其实并不是一个产品,而是一些独立模块的组合.主要有分布式文件系统HDFS和 ...
- form 回车键(ENTER)
<form class="clb_yyxx_nr" name="appointment_content" action="" onsu ...
- jconsole监控tomcat
一.专业术语 GC垃圾回收机制:当需要分配的内存空间不再使用的时候,JVM将调用垃圾回收机制来回收内存空间. JMX(Java Management Extensions,即Java管理扩展)是一个为 ...
- Linux系统下修改MySQL密码(忘记密码)
忘记原来的myql的root的密码: 首先,你必须要有操作系统的root权限了.要是连系统的root权限都没有的话,先考虑root系统再走下面的步骤.类似于安全模式登录系统,有人建议说是pkill m ...
- python入门(八):连接mysql和STMP
Python3 MySQL 数据库连接,使用 PyMySQL 连接数据库,并实现简单的增删改查. mysql连接步骤 1.打开数据库连接 2.使用cursor()方法获取操作游标 3.执行sql和异 ...
- web测试点--摘录
转载地址:Web测试到底是在测什么 一.输入框 1.字符型输入框: (1)字符型输入框:英文全角.英文半角.数字.空或者空格.特殊字符“~!@#¥%……&*?[]{}”特别要注意单引号和&am ...
- 【转】SignalR来做实时Web聊天
本章和大家分享的内容是使用Signal R框架创建个简易的群聊功能,主要讲解如何在.Net的MVC中使用这个框架,由于这个项目有官方文档(当然全英文),后面也不打算写分享篇了,主要目的是让朋友们在需要 ...
- Web容器与Servlet
转自:http://www.360doc.com/content/10/0713/20/495229_38798294.shtml Web服务器与Web应用层属于不容两个范畴,为了让他们两写作,首先应 ...
- Exchange Database Status(Copy Status ,Content Index State,QueueLength,Move Status...)
Copy Status Description Mounted The active copy is online and accepting client connections. Only the ...