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 ...
随机推荐
- linux(ubuntu)环境下安装IDEA
想调试java虚拟机内存溢出的情况,在调试过程中总会出现一些不可预见的状况,正好在学linux,在windows上安装了虚拟机,安装的镜像是ubuntu(乌班图)装在了虚拟机中,装在虚拟机中好处是即使 ...
- [POJ1050] To the Max 及最大子段和与最大矩阵和的求解方法
最大子段和 Ο(n) 的时间求出价值最大的子段 #include<cstdio> #include<iostream> using namespace std; int n,m ...
- Java注解学习笔记
我们平常写Java代码,对其中的注解并不是很陌生,比如说写继承关系的时候经常用到@Override来修饰方法.但是@Override是用来做什么的,为什么写继承方法的时候要加上它,不加行不行.如果对J ...
- heartbeat错误排查
错误一: [root@snale2 ha.d ::]#service heartbeat start Starting High-Availability services: INFO: Resour ...
- Laravel 中缓存驱动的速度比较
缓存是web开发中重要的一部分,我相信很多人和我一样,经常忽略这个问题. 随着工作经验的累积,我已经意识到缓存是多么的重要,这里我通过 Scotch 来解释一下它的重要性. 通过观察发现,Scotch ...
- js面向对象的理解
ECMAScript 有两种开发模式:1.函数式(过程化),2.面向对象(OOP).面向对象的语言有一个标志,那就是类的概念,而通过类可以创建任意多个具有相同属性和方法的对象.但是,ECMAScrip ...
- Java基础学习笔记十四 常用API之基本类型包装类
基本类型包装类 Java中有8种基本的数据类型,可是这些数据是基本数据,想对其进行复杂操作,变的很难.怎么办呢?在实际程序使用中,程序界面上用户输入的数据都是以字符串类型进行存储的.而程序开发中,我们 ...
- python web——Django架构
环境:windows/linux/OS 需要的软件:Firefox 浏览器(别的也可以 不过firfox和python的webdriver兼容性好) git版本控制系统(使用前要配置 用户 编辑器可以 ...
- C语言第九次作业
一.PTA实验作业 题目1:统计大于等于平均分人数 1. 本题PTA提交列表 2.设计思路 float i为循环变量,sum=0,count=0来表示所求人数 float *p=s来储存首地址 for ...
- http post/get 2种使用方式
public class HttpUtil { //HttpPost public static String executePost(String url, List<NameValue ...