hdu2062 Subset sequence----递推
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=2062
题目大意:
给出n和m,集合{1,2,,,,n}的非空子集,按照一定方式排列,例如n==3时,
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int cases;
const int maxn = 1e5 + ;
typedef long long ll;
ll n, m, a[];
void init()
{
a[] = ;
for(ll i = ; i < ; i++)a[i] = i * (a[i - ] + );
//for(int i = 1; i <= 20; i++)cout<<a[i]<<endl;
}
int main()
{
init();
while(cin >> n >> m)
{
int b[], ans[], tot = ;
for(int i = ; i <= n; i++)b[i] = i;
while(m > )
{
int c = (m + a[n - ]) / (a[n - ] + );
//cout<<m << " "<<c<<" "<< n<<endl;
ans[tot++] = b[c];
n--;
for(int i = c; i <= n; i++)b[i] = b[i + ];
m -= (c - ) * (a[n] + );
m--;
if(m <= )break; }
cout<<ans[];
for(int i = ; i < tot; i++)cout<<" "<<ans[i];
cout<<endl;
}
}
hdu2062 Subset sequence----递推的更多相关文章
- HDU 5860 Death Sequence(递推)
HDU 5860 Death Sequence(递推) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 Description You ...
- hdu-5496 Beauty of Sequence(递推)
题目链接: Beauty of Sequence Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65536/65536 K (Java ...
- HDU 5950 Recursive sequence 递推转矩阵
Recursive sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- hdu 5860 Death Sequence(递推+脑洞)
Problem Description You may heard of the Joseph Problem, the story comes from a Jewish historian liv ...
- hdu 5950 Recursive sequence 递推式 矩阵快速幂
题目链接 题意 给定\(c_0,c_1,求c_n(c_0,c_1,n\lt 2^{31})\),递推公式为 \[c_i=c_{i-1}+2c_{i-2}+i^4\] 思路 参考 将递推式改写\[\be ...
- bzoj 2656 [Zjoi2012]数列(sequence) 递推+高精度
2656: [Zjoi2012]数列(sequence) Time Limit: 2 Sec Memory Limit: 128 MB[Submit][Status][Discuss] Descri ...
- HDU 5950 Recursive sequence 【递推+矩阵快速幂】 (2016ACM/ICPC亚洲区沈阳站)
Recursive sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Other ...
- HDU5950 Recursive sequence (矩阵快速幂加速递推) (2016ACM/ICPC亚洲赛区沈阳站 Problem C)
题目链接:传送门 题目: Recursive sequence Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total ...
- POJ_1019 Number Sequence 【递推】
题目: A single positive integer i is given. Write a program to find the digit located in the position ...
- POJ_2478 Farey Sequence 【欧拉函数+简单递推】
一.题目 The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbe ...
随机推荐
- 部署Flask项目到腾讯云服务器CentOS7
部署Flask项目到腾讯云服务器CentOS7 安装git yum install git 安装依赖包 支持SSL传输协议 解压功能 C语言解析XML文档的 安装gdbm数据库 实现自动补全功能 sq ...
- maven依赖大全
1.oracle mysql驱动 <!-- mysql驱动支持 --> <dependency> <groupId>mysql</groupId> &l ...
- Quikapp快应用开发入门
快应诞生背景 微信的小程序使得很多原来需要调动APP的场景不复存在,正式由于微信小程序的冲击,3月20日,华为联手九大手机厂商,共同举办了“快应用”标准启动发布会.“快应用”是几家手机厂商基于硬件平台 ...
- 设计模式 --> (17)状态模式
状态模式 允许一个对象在其内部状态改变时改变它的行为.对象看起来似乎修改了它的类.它有两种使用情况: (1)一个对象的行为取决于它的状态, 并且它必须在运行时刻根据状态改变它的行为. (2)一个操作中 ...
- 常用排序算法的Java实现与分析
由于需要分析算法的最好时间复杂度和最坏时间复杂度,因此这篇文章中写的排序都是从小到大的升序排序. 带排序的数组为arr,arr的长度为N.时间复杂度使用TC表示,额外空间复杂度使用SC表示. 好多代码 ...
- centos 7.0远程登录
http://blog.csdn.net/e1219092641/article/details/79586476 linux在虚拟机上操作也是有许多不便之处的,但是远程登录的使用可以使操作简单不少, ...
- c语言博客作业-指针
一.PTA实验作业 题目1: 1. 本题PTA提交列表 2. 设计思路(用代码表示扣分) 定义整型变量i,count记录平均分,实型变量sum保存总分 for i=0 to n sum = sum+* ...
- 《Language Implementation Patterns》之 增强解析模式
上一章节讲述了基本的语言解析模式,LL(k)足以应付大多数的任务,但是对一些复杂的语言仍然显得不足,已付出更多的复杂度.和运行时效率为代价,我们可以得到能力更强的Parser. Pattern 5 : ...
- Flask 测试
测试是每个应用系统发布前必须经历的步骤,自动化测试对测试效率的提高也是毋庸置疑的.对于Flask应用来说,当然可以使用Web自动化测试工具,比如Selenium等来测.Flask官方推荐的自动化测试方 ...
- DML数据操作语言之增加,删除,更新
1.数据的增加 数据的增加要用到insert语句 ,基本格式是: insert into <表名> (列名1,列名2,列名3,......) values (值1,值2,值3,..... ...