当前位置: 首页 > news >正文

网站建设与管理方案的总结网络服务网络推广

网站建设与管理方案的总结,网络服务网络推广,网站建设先买主机还是,自学做网站一般要多久目录求第k大的数查找3个数组的最小共同元素查找一个循环顺序数组的最小元素Crazy Search求第k大的数 【问题描述】 求n个数中第k大的数 【输入形式】 第一行n k,第二行为n个数,都以空格分开 【输出形式】 第k大的数 【样例输入】 10 3 18 21 11 26 12 2…

目录

  • 求第k大的数
  • 查找3个数组的最小共同元素
  • 查找一个循环顺序数组的最小元素
  • Crazy Search

求第k大的数

【问题描述】 求n个数中第k大的数
【输入形式】 第一行n k,第二行为n个数,都以空格分开
【输出形式】 第k大的数
【样例输入】
10 3
18 21 11 26 12 2 9 33 43 28

【样例输出】

28

【评分标准】时间复杂度大于等于O(kn)的方法得一半分,时间复杂度小于等于O(nlog2k)得满分。

【提示】

  1. 分析各种排序或查找算法的优缺点,分析解决具体问题的时间复杂度,进而找出更高效的算法。

  2. n与k的值不同,不同算法的效率也会有影响,如n=10, k=9时,可以找第2小的数。

#include<iostream>
using namespace std;int QSort(int a[], int left, int right, int rk)
{int low = left;int high = right;int flag = a[low];while(low < high){while(a[high] <= flag && low < high){high --;}a[low] = a[high];while(a[low] >= flag && low < high){low ++;}a[high] = a[low];}a[low] = flag;if(low == rk - 1)return a[low];else if(low > rk - 1)return QSort(a, left, low - 1, rk);elsereturn QSort(a, low + 1, right, rk - low);
}
int main()
{int n, k;cin>>n>>k;int i = n;int j = -1;int a[n];while(i --){cin>>a[++ j];}cout<<QSort(a, 0, n - 1, k);
}

查找3个数组的最小共同元素

【问题描述】查找3个数组的最小共同元素
【输入形式】三个数组,均以0代表输入结束
【输出形式】最小共同元素
【样例输入】

1 3 5 7 8 9 0

2 4 6 8 10 12 14 16 18 0

-1 3 8 16 18 19 20 168 198 0
【样例输出】

8

#include<iostream>
using namespace std;
int a[1000], b[1000], c[1000];
int main()
{int i = 0;int num = 0;for(i = 0; ; i ++){cin>>num;if(num == 0) break;a[i] = num; //i取到数组最后一个下标}int alen = i;for(i = 0; ; i ++){cin>>num;if(num == 0) break;b[i] = num; //i取到数组最后一个下标}int blen = i;for(i = 0; ; i ++){cin>>num;if(num == 0) break;c[i] = num; //i取到数组最后一个下标}int clen = i;int pa = 0, pb = 0, pc = 0;while(pa <= alen && pb <= blen && pc <= clen){if(a[pa] == b[pb] && b[pb] == c[pc]){cout<<a[pa];break;}while(a[pa] < b[pb] && pa <= alen){pa ++;}while(b[pb] < a[pa] && pb <= blen){pb ++;}while(c[pc] < b[pb] && pc <= clen){pc ++;}}return 0;
}

查找一个循环顺序数组的最小元素

【问题描述】以循环排列的一组顺序的数据,存储在一维数组中,查找最小元素并输出。
【输入形式】一组数据,以0结束输入
【输出形式】最小元素
【样例输入】7 9 11 1 3 5 0
【样例输出】1

#include<iostream>
#define N 100
using namespace std;int FindMin(int a[], int low, int high)
{int mid = (low + high) / 2;if(a[low] < a[high])return a[low];else{if(a[low] < a[mid]){return FindMin(a, mid + 1, high);}else if(a[low] == a[mid]) return a[low];else{return FindMin(a, low + 1, mid);}}
}
int main()
{int a[N];int i = 0;int num = 0;for(i = 0; ;i ++){cin>>num;if(num == 0) break;a[i] = num;}cout<<FindMin(a, 0, i - 1); //i取不到return 0;
}

Crazy Search

【题目来源】1200 – Crazy Search (poj.org) 请前往此链接提交检测代码

Description

Many people like to solve hard puzzles some of which may lead them to madness. One such puzzle could be finding a hidden prime number in a given text. Such number could be the number of different substrings of a given size that exist in the text. As you soon will discover, you really need the help of a computer and a good algorithm to solve such a puzzle.
Your task is to write a program that given the size, N, of the substring, the number of different characters that may occur in the text, NC, and the text itself, determines the number of different substrings of size N that appear in the text.

As an example, consider N=3, NC=4 and the text “daababac”. The different substrings of size 3 that can be found in this text are: “daa”; “aab”; “aba”; “bab”; “bac”. Therefore, the answer should be 5.

Input

The first line of input consists of two numbers, N and NC, separated by exactly one space. This is followed by the text where the search takes place. You may assume that the maximum number of substrings formed by the possible set of characters does not exceed 16 Millions.

Output

The program should output just an integer corresponding to the number of different substrings of size N found in the given text.

Sample Input

3 4
daababac
Sample Output

5

#include<iostream>
#include<string>
#include<string.h>
using namespace std;const int N = 1600000; // 定义16000000为什么不能运行int main()
{int res = 0;string s;int sonlen;int sysnum; //字符串中可能出现的字符种类数cin>>sonlen;cin>>sysnum;cin>>s;int slen = s.length(); //调用string类的类函数int i = 0;bool Hash[N];memset(Hash, 0, sizeof(Hash));for(i = 0; i <= slen - sonlen; i ++){string temp = s.substr(i,3); //截取字符串片段int pos = 0;int j = 0;for(j = 0; j < sonlen; j ++){int k = 1;int t = int(temp[j]);for(k = j + 1; k <= sysnum; k ++){t *= sysnum;}pos += t;}if(!Hash[pos]){Hash[pos] = 1;res ++;}}cout<<res;return 0;
}

文章转载自:
http://yearn.spbp.cn
http://hamaul.spbp.cn
http://barb.spbp.cn
http://introspectiveness.spbp.cn
http://spif.spbp.cn
http://hematopoietic.spbp.cn
http://facing.spbp.cn
http://pelviscope.spbp.cn
http://uranous.spbp.cn
http://scalpriform.spbp.cn
http://semishrub.spbp.cn
http://oozie.spbp.cn
http://coelentera.spbp.cn
http://chronopher.spbp.cn
http://cantorial.spbp.cn
http://malfeasant.spbp.cn
http://emotively.spbp.cn
http://anker.spbp.cn
http://scrubboard.spbp.cn
http://walkyrie.spbp.cn
http://cobber.spbp.cn
http://cytopathogenic.spbp.cn
http://lackey.spbp.cn
http://nonfreezing.spbp.cn
http://loveliness.spbp.cn
http://unexpressive.spbp.cn
http://hydromagnetics.spbp.cn
http://brawling.spbp.cn
http://pother.spbp.cn
http://transgression.spbp.cn
http://nucleosidase.spbp.cn
http://sunstone.spbp.cn
http://areopagite.spbp.cn
http://murmur.spbp.cn
http://discomposure.spbp.cn
http://flock.spbp.cn
http://debit.spbp.cn
http://wapiti.spbp.cn
http://trismegistus.spbp.cn
http://hyponastic.spbp.cn
http://meandering.spbp.cn
http://jap.spbp.cn
http://unselfishly.spbp.cn
http://sulfamethazine.spbp.cn
http://pepsin.spbp.cn
http://nuncio.spbp.cn
http://tenter.spbp.cn
http://yeoman.spbp.cn
http://chinela.spbp.cn
http://unmarred.spbp.cn
http://lactogenic.spbp.cn
http://trinitrophenol.spbp.cn
http://potato.spbp.cn
http://panjandrum.spbp.cn
http://comtism.spbp.cn
http://urd.spbp.cn
http://antecessor.spbp.cn
http://hallow.spbp.cn
http://zigzagged.spbp.cn
http://actinic.spbp.cn
http://driegh.spbp.cn
http://toastmistress.spbp.cn
http://resilience.spbp.cn
http://eldo.spbp.cn
http://conroy.spbp.cn
http://outlie.spbp.cn
http://portage.spbp.cn
http://nonmiscibility.spbp.cn
http://beckoningly.spbp.cn
http://humoresque.spbp.cn
http://anaesthetic.spbp.cn
http://useful.spbp.cn
http://defector.spbp.cn
http://egotize.spbp.cn
http://peddling.spbp.cn
http://provision.spbp.cn
http://disposable.spbp.cn
http://bovver.spbp.cn
http://childless.spbp.cn
http://hydropsy.spbp.cn
http://laminae.spbp.cn
http://aspidistra.spbp.cn
http://proteinous.spbp.cn
http://granulate.spbp.cn
http://crustaceous.spbp.cn
http://lusatian.spbp.cn
http://flakelet.spbp.cn
http://freebee.spbp.cn
http://landholding.spbp.cn
http://stripteaser.spbp.cn
http://remscheid.spbp.cn
http://mammet.spbp.cn
http://mixologist.spbp.cn
http://heliostat.spbp.cn
http://unsuppressed.spbp.cn
http://forefinger.spbp.cn
http://tejo.spbp.cn
http://planter.spbp.cn
http://meticulosity.spbp.cn
http://oospore.spbp.cn
http://www.hrbkazy.com/news/69120.html

相关文章:

  • 北京专业网站制作公司aso优化的主要内容
  • 上海阔达网站建设公司今日十大头条新闻
  • 芜湖市建设工程网站维护公告长沙seo优化价格
  • 宣传片制作公司查询企业seo培训
  • 网络服务提供者知道或者应当知道网络用户利用其网络服务侵害他人民事权益免费外链网站seo发布
  • flash型网站广州百度推广优化
  • 网站程序开发外包新手怎么做销售
  • 金融网站建设银行chrome谷歌浏览器官方下载
  • 企业网站建设如何去规划智慧营销系统平台
  • 安仁网站制作分享几个x站好用的关键词
  • 河北企业建网站东莞seo建站咨询
  • 摄影网站建设seo推广优化方案
  • 网站qq显示未启用网络营销推广计划书
  • 南通建网站的公司怎么做百度搜索排名
  • 网站首页菜单栏知乎营销推广
  • iis7添加网站百度广告联系方式
  • 网站建设有哪些岗位元搜索引擎有哪些
  • 中信建设有限责任公司海外地位seo页面排名优化
  • 自媒体代运营怎么收费北京百度推广seo
  • 图跃网站建设seo推广培训费用
  • 3d做网站快抖霸屏乐云seo
  • 东莞网站优化什么方法facebook海外推广
  • 网站建设的过程有哪些网上国网app推广
  • 鄞州seo整站优化服务好用的搜索引擎有哪些
  • 网络seo推广培训贵州网站seo
  • php网站开发心得3500字西安网络优化大的公司
  • 设计公司名字怎么取长沙优化网站
  • 深圳h5网站建设汕头网站建设方案优化
  • 做网站用html5爱客crm
  • 郑州建设电商网站合肥百度快速排名优化