HDUOJ --2523
2024-09-03 11:15:55
哈希表..球阀
代码:
#include<iostream>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<functional>
using namespace std;
bool hash[];
int main()
{
int c,n,k,i,j;
scanf("%d",&c);
while(c--)
{
scanf("%d%d",&n,&k);
memset(hash,,sizeof(hash));
vector<int>sav(n);
for(i=;i<n;i++)
scanf("%d",&sav[i]);
sort(sav.begin(),sav.end(),less<int>());
for(i=;i<n;i++)
{
for(j=i+;j<n ;j++)
{
hash[sav[j]-sav[i]]=true;
}
}
for(i=;i<=&&k>;i++)
{
if(hash[i]) k--;
}
printf("%d\n",i-);
}
return ;
}
想到过很多方法,都超时了,看了别人的代码,才发现,有这么一出,居然没想到...爱,菜鸟,终究是菜鸟...
最新文章
- hive 内部表和外部表的区别和理解
- idea key
- jQuery简单入门(三)
- JBOSS只能本机localhost和127.0.0.1能访问的解决
- cocos2dx 3.0 之 lua 创建类 (二)
- 设置Tomcat根目录
- LeetCode 278
- 查看linux中的TCP连接数【转】
- 第一篇、CSS3_transtion的使用
- 关于 ASP.NET MVC 4 如果管理用户
- 使用Bugfree不应有的坏习惯
- opencv基础知识-videowriter
- [转]CSS vertical-align属性详解 作者:黄映焜
- Activity的onSaveInstanceState()和onRestoreInstanceState()以及API详解
- [Python]How to handle the exception in Python?
- 九、使用多线程——NSThread,GCD和NSOperation
- 《Android进阶之光》--RxJava结合Retrofit访问网络
- Android UI系列-----RelativeLayout的相关属性
- ajax post get
- [knowledge][bigdata] nosql
热门文章
- RuntimeError: Working outside of application context.
- 21.重入锁ReentrantLock
- C 语言:返回两个数组中第一个相同元素的指针(我用了loop 、goto loop标签)
- WampServer和phpStorm的用法
- Entity Framework泛型封装
- HDU 4576 Robot (概率DP)
- MFC COM调用时出现E_OUTOFMEMORY错误
- 如何在程序中使用CString
- Java 正则表达式提取标签中的属性(src 连接地址)等
- 【nodejs】理想论坛帖子下载爬虫1.06