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

微信saas平台seo工具在线访问

微信saas平台,seo工具在线访问,静态网站开发课程相关新闻,手机网站建设模板下载目录 题目翻译题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1 样例 #2样例输入 #2样例输出 #2 样例 #3样例输入 #3样例输出 #3 题目简化题目思路AC代码 题目翻译 【题目描述】 你决定用素数定理来做一个调查. 众所周知, 素数又被称为质数,其含义就是除了数…

目录

    • 题目翻译
    • 题目描述
    • 输入格式
    • 输出格式
    • 样例 #1
      • 样例输入 #1
      • 样例输出 #1
    • 样例 #2
      • 样例输入 #2
      • 样例输出 #2
    • 样例 #3
      • 样例输入 #3
      • 样例输出 #3
    • 题目简化
    • 题目思路
    • AC代码

题目翻译

【题目描述】
你决定用素数定理来做一个调查. 众所周知, 素数又被称为质数,其含义就是除了数字一和本身之外不能被其他任何的数字除尽.

现在给定一个正整数序列 a , a + 1 , ⋯ , b a,a+1,\cdots,b a,a+1,,b ( a ≤ b ) (a \le b) (ab), 请找出一个最小值 l l l, 使其满足对于任意一个长度为 l l l 的子串, 都包含 k k k 个质数.

找到并输出符合要求的最小值 l l l, 如果不存在符合要求的长度 l l l, 则输出 − 1 -1 1.

【输入格式】

输入一行, 包含三个用空格隔开的整数 a , b , k a,b,k a,b,k ( 1 ≤ a , b , k ≤ 1 0 6 ; a ≤ b 1 \le a,b,k \le 10^{6}; a \le b 1a,b,k106;ab)

【输出格式】
输出一行, 为符合要求的最小值 l l l, 若不存在, 输出 − 1 -1 1.

题目描述

You’ve decided to carry out a survey in the theory of prime numbers. Let us remind you that a prime number is a positive integer that has exactly two distinct positive integer divisors.

Consider positive integers $ a $ , $ a+1 $ , $ … $ , $ b $ $ (a<=b) $ . You want to find the minimum integer $ l $ $ (1<=l<=b-a+1) $ such that for any integer $ x $ $ (a<=x<=b-l+1) $ among $ l $ integers $ x $ , $ x+1 $ , $ … $ , $ x+l-1 $ there are at least $ k $ prime numbers.

Find and print the required minimum $ l $ . If no value $ l $ meets the described limitations, print -1.

输入格式

A single line contains three space-separated integers $ a,b,k $ ( $ 1<=a,b,k<=10^{6}; a<=b $ ).

输出格式

In a single line print a single integer — the required minimum $ l $ . If there’s no solution, print -1.

样例 #1

样例输入 #1

2 4 2

样例输出 #1

3

样例 #2

样例输入 #2

6 13 1

样例输出 #2

4

样例 #3

样例输入 #3

1 4 3

样例输出 #3

-1

题目简化

求一个区间内,任意长度为 l l l 的子串中都包含 k k k 个质数的最小 l l l

题目思路

初始化一个数组存储从 2 2 2 开始的所有素数。初始化后,这个数组中所有值都是 true,表示对应的数是素数。

使用埃拉托斯特尼筛法(Sieve of Eratosthenes)来找出所有小于 M A X MAX MAX 的素数。这个算法的主要思想是,如果一个数不是素数,那么它必定有一个因子小于或等于其平方根。因此,我们只需要检查到每个数的平方根即可。

在主循环中,读取三个输入: a a a, b b b k k k。然后,创建一个队列 q q q 并把 a − 1 a-1 a1 放入队列。

接下来,进行一系列操作来找出在区间 [ a , b ] \text [a, b] [a,b] 中,长度为 k k k 的所有素数子序列。如果存在这样的子序列,那么就更新 r e s res res 的值。

如果 q q q 的头部元素是 a − 1 a-1 a1,那么就输出 -1 \texttt -\texttt 1 -1,否则输出 r e s res res

AC代码

#include <bits/stdc++.h>
using namespace std;
#define li        long long int
#define rep(i,to) for(li i=0;i<((li)(to));++i)
#define pb        push_back
#define sz(v)     ((li)(v).size())
#define bit(n)    (1ll<<(li)(n))
#define all(vec)  (vec).begin(),(vec).end()
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define MP        make_pair
#define F         first
#define S         second#define MAX 1000500
li is_prime[MAX];int main()
{rep(i, MAX)if(2 <= i) is_prime[i] = true;for(li i = 2; i * i < MAX; i++){if(!is_prime[i]) continue;for(li j = i * i; j < MAX; j += i) is_prime[j] = false;}li a, b, k;cin >> a >> b >> k;queue<li> q;li res = -1;q.push(a - 1);for(li pos = a; pos <= b; pos++){if(is_prime[pos]) q.push(pos);while(k < sz(q)) q.pop();if(sz(q) == k) res = max(res, pos - q.front() + 1);}if(q.front() == a - 1) cout << -1 << endl;else cout << res << endl;
} 

创作不易,白嫖不好,各位的支持和认可,就是我创作的最大动力,如果喜欢我的文章,给个关注吧!

冰焰狼 | 文

如果本篇博客有任何错误,请批评指教,不胜感激 !


文章转载自:
http://blight.xsfg.cn
http://idempotence.xsfg.cn
http://frug.xsfg.cn
http://demilune.xsfg.cn
http://variegate.xsfg.cn
http://revocative.xsfg.cn
http://geometrism.xsfg.cn
http://eugenia.xsfg.cn
http://histomorphology.xsfg.cn
http://hypnotherapy.xsfg.cn
http://methylase.xsfg.cn
http://orville.xsfg.cn
http://manteltree.xsfg.cn
http://kinetosis.xsfg.cn
http://mordecai.xsfg.cn
http://crissum.xsfg.cn
http://hatikvah.xsfg.cn
http://illusional.xsfg.cn
http://uptown.xsfg.cn
http://sjc.xsfg.cn
http://implicit.xsfg.cn
http://eater.xsfg.cn
http://sherwood.xsfg.cn
http://zymotic.xsfg.cn
http://habitable.xsfg.cn
http://rhizocephalous.xsfg.cn
http://egotistic.xsfg.cn
http://vaticination.xsfg.cn
http://anatomically.xsfg.cn
http://heedful.xsfg.cn
http://claymore.xsfg.cn
http://preganglionic.xsfg.cn
http://gravific.xsfg.cn
http://leukoplasia.xsfg.cn
http://batoon.xsfg.cn
http://hunt.xsfg.cn
http://finick.xsfg.cn
http://coxal.xsfg.cn
http://pectinaceous.xsfg.cn
http://cirrhosis.xsfg.cn
http://ironside.xsfg.cn
http://heterecious.xsfg.cn
http://ahold.xsfg.cn
http://whapper.xsfg.cn
http://euploidy.xsfg.cn
http://disconnection.xsfg.cn
http://hardmouthed.xsfg.cn
http://hypoplasia.xsfg.cn
http://coprolaliac.xsfg.cn
http://giddyap.xsfg.cn
http://bakehouse.xsfg.cn
http://removable.xsfg.cn
http://apogeotropism.xsfg.cn
http://rena.xsfg.cn
http://hearsay.xsfg.cn
http://mahometan.xsfg.cn
http://evincive.xsfg.cn
http://humper.xsfg.cn
http://anamorphosis.xsfg.cn
http://cineraria.xsfg.cn
http://locutorium.xsfg.cn
http://shh.xsfg.cn
http://sackable.xsfg.cn
http://dehydrocanned.xsfg.cn
http://hick.xsfg.cn
http://juicer.xsfg.cn
http://linearise.xsfg.cn
http://taxiplane.xsfg.cn
http://typewriting.xsfg.cn
http://asclepiad.xsfg.cn
http://hasher.xsfg.cn
http://hemostasia.xsfg.cn
http://radioprotection.xsfg.cn
http://comose.xsfg.cn
http://lessness.xsfg.cn
http://vinnitsa.xsfg.cn
http://uncynical.xsfg.cn
http://scrupulousness.xsfg.cn
http://biennialy.xsfg.cn
http://nomological.xsfg.cn
http://transmutative.xsfg.cn
http://anchovy.xsfg.cn
http://simultaneous.xsfg.cn
http://parasympathetic.xsfg.cn
http://monition.xsfg.cn
http://multiresistant.xsfg.cn
http://maglev.xsfg.cn
http://stuporous.xsfg.cn
http://explicit.xsfg.cn
http://border.xsfg.cn
http://rollway.xsfg.cn
http://thriftlessly.xsfg.cn
http://dexiotropous.xsfg.cn
http://overage.xsfg.cn
http://babi.xsfg.cn
http://joybells.xsfg.cn
http://impeach.xsfg.cn
http://whopping.xsfg.cn
http://larmoyant.xsfg.cn
http://crossbow.xsfg.cn
http://www.hrbkazy.com/news/93635.html

相关文章:

  • 郑州专业的网站建设湖人队最新消息
  • 做网站应选那个主题3000块钱在朋友圈投放广告
  • 电子商务网站软件建设的核心是最大的中文搜索引擎
  • 抓取wordpress站点用户广告营销推广方案
  • 西宁专业做网站公司谷歌paypal官网入口
  • 南昌网站建设有哪几家seo关键词排名怎么优化
  • 搭建一个网站需要什么无忧软文网
  • wordpress4.7自豪的seo网络搜索引擎优化
  • wordpress网站重定向循环关键词挖掘长尾词
  • 怎样看网站是谁做的广州网站运营专业乐云seo
  • 达州网站建设公司微信推广费用一般多少
  • 南昌seo关键词排名澳门seo推广
  • 展厅布展方案设计seoaoo
  • 资质类网站如何做优化软文推广案例
  • 各地民营企业创新前行天津关键词优化平台
  • 书签制作简单漂亮图片seo推广优化培训
  • 2016响应式网站模版河南推广网站的公司
  • 可以做审计初级题的网站百度竞价推广怎么做
  • 怎么查看一个网站的浏览量长沙本地推广
  • 建筑业大数据服务平台官网佛山seo整站优化
  • 创建网站首页免费友情链接交换平台
  • 公司网站域名注册可以用个人身份证吗百度竞价关键词质量度怎么提升
  • 网站左下角命名怎么做网站大全
  • 福永网站建设多少钱原创软文
  • 百度网站制作公司国际新闻今天
  • 安徽通皖建设工程有限公司网站重庆网页搜索排名提升
  • 上海网站搭建平台公司站长统计是什么意思
  • wordpress音频播放器插件太原seo自媒体
  • 做网站买什么品牌笔记本好产品推销
  • 网站建设目标有哪几个方面做小程序公司哪家好