Given a sequence of positive integers and another positive integer p. The sequence is said to be a perfect sequence if Mm×p where M and m are the maximum and minimum numbers in the sequence, respectively.

Now given a sequence and a parameter p, you are supposed to find from the sequence as many numbers as possible to form a perfect subsequence.

Input Specification:

Each input file contains one test case. For each case, the first line contains two positive integers N and p, where N (≤10​5​​) is the number of integers in the sequence, and p (≤10​9​​) is the parameter. In the second line there are N positive integers, each is no greater than 10​9​​.

Output Specification:

For each test case, print in one line the maximum number of integers that can be chosen to form a perfect subsequence.

Sample Input:

10 8
2 3 20 4 5 1 6 7 8 9

Sample Output:

8
注意点:1.int*int 的范围必须用long long;
    2.if(a[n-1]<=x) return n;
 #include<bits/stdc++.h>
using namespace std; const int maxn =; int a[maxn]; int n,p; int binary_Search(int i,long long x){ if(a[n-]<=x)
return n; int left=i+,right=n-; while(left<right){
int mid = (left+right)/; if(a[mid]>x){
right =mid;
}else{
left= mid+;
}
} return left; } int main(){ cin>>n>>p; for(int i=;i<n;i++)
cin>>a[i]; sort(a,a+n); int ans=; for(int i=;i<n;i++){ // int j=binary_Search(i,(long long)a[i]*p); int j=upper_bound(a+i+,a+n,(long long)a[i]*p)-a; ans=max(ans,j-i); // cout<<j<<" "<<i<<endl;
} cout<<ans<<endl; return ; }

最新文章

  1. Fedora 23 忘记root密码
  2. 区间重叠计算及IntervalTree初识
  3. 用Python套接字创建HTTP客户与服务器程序
  4. AgileEAS.NET SOA 中间件2013第四季度发布&amp;部分功能开源预告
  5. 最新版ffmpeg源码分析
  6. js倒计时防页面刷新
  7. Java基础之写文件——从多个缓冲区写(GatheringWrite)
  8. fl,flash,mx包的区别
  9. 得到当前网址的域名 ASP.NET
  10. TableView 多余分割线的处理
  11. EDP转换IC NCS8801S:RGB/LVDS转EDP芯片
  12. 201521123102 《Java程序设计》第1周学习总结
  13. 如何解决在ie下,Echarts多次使用setOption更改数据时,数据错乱问题
  14. linux下的$0-n作用
  15. Excel转datatable
  16. iframe和ajax文件上传方法
  17. html可用于跨域的三个标签
  18. lombok 一个不错的小工具
  19. winform TreeView 节点选择
  20. 170605、防止sql注入(二)

热门文章

  1. 7.使用mysql_export监控mysql
  2. 25. Postman的使用
  3. upc组队赛1 小C的数学问题【单调栈】(POJ2796)
  4. Idea添加Tomcat
  5. nginx中root与alias关键字的区别
  6. Linux 2.6.x fs/pipe.c local kernel root(kit?) exploit (x86)
  7. ArcGis 创建Annotation注记要素类、添加注记要素 并加载到Activeview AO C#
  8. EXCEL数据计算不准确的问题
  9. sysprep
  10. 互斥量mutex简介