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 ...
随机推荐
- 关于html文档的规范
1. <!DOCTYPE html> 告诉浏览器该文档使用哪种html或xhtml的规范 2. 元数据中的X-UA-Compatible <meta http-equiv=" ...
- windows 设置/修改全局快捷键
打开控制面板,小图表显示下 点击 管理工具项, 将自己想要谁知快捷键的程序的快捷方式放进去,(需要确认管理员权限) 如图,第一个即为 lz添加的 右击选择属性 在快捷键处同时按下你想要的组合键即可(不 ...
- RxJS速成 (上)
What is RxJS? RxJS是ReactiveX编程理念的JavaScript版本.ReactiveX是一种针对异步数据流的编程.简单来说,它将一切数据,包括HTTP请求,DOM事件或者普通数 ...
- 【Django】 rest-framework和RestfulAPI的设计
[rest-framework] 这是一个基于django才能发挥作用的组件,专门用于构造API的. 说到API,之前在其他项目中我也做过一些小API,不过那些都是玩票性质,结构十分简单而且要求的设计 ...
- Spring Boot with Spring-Data-JPA学习案例
0x01 什么是Spring Boot? Spring Boot是用来简化Spring应用初始搭建以及开发过程的全新框架,被认为是Spring MVC的"接班人",和微服务紧密联系 ...
- Jmeter中正则表达式提取器使用详解
在使用Jmeter过程中,会经常使用到正则表达式提取器提取器,虽然并不直接涉及到请求的测试,但是对于数据的传递起着很大的作用,本篇博文就是主要讲解关于正则表达式及其在Jmeter的Sampler中的调 ...
- ConcurrentHashMap、synchronized与线程安全
明明用了ConcurrentHashMap,可是始终线程不安全, 下面我们来看代码: public class Test40 { public static void main(String[] ar ...
- Maven安装配置【WIN10】
环境 WIN10 Maven 3.5.3 下载 下载地址:https://maven.apache.org/download.cgi 安装配置 选择好路径后一路 next 默认,安装完成. 环境变量设 ...
- JavaScript之隐式类型转换
布尔操作符(!.&&.||) 当使用 条件判断语句(if...else) 以及 布尔操作符(!.&&.||) 时,会调用Boolean()进行隐式类型转换 转换为fal ...
- 启动django应用报错 “Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试。”
启动django应用时报如下错误 "Error: [WinError 10013] 以一种访问权限不允许的方式做了一个访问套接字的尝试." 网上查了一下,是8000端口被其他程序占 ...