当前位置:网站首页>B. Construct a simple sequence (greedy)
B. Construct a simple sequence (greedy)
2022-08-04 14:18:00 【Harris-H】
B.Construct a simple sequence of numbers(贪心)
Whether each judgment satisfies the mutual prime,Not satisfied to join the candidate queue,Then when one is satisfied, add the queue to the back.
#include<bits/stdc++.h>
using namespace std;
int a[1000005];
int main(){
int n;
cin>>n;
while(n--){
int x,y;
cin>>x>>y;
a[1]=x;
int cnt=1;
queue<int>q;
for(int i=1;cnt<=y;i++){
if(i==x)continue;
if(__gcd(a[cnt],i)==1){
a[++cnt]=i;
while(!q.empty()){
a[++cnt]=q.front();
q.pop();
}
}
else{
q.push(i);
}
}
cout<<a[y]<<"\n";
}
return 0;
}
边栏推荐
- LM2596有没有可以替代的?LM2576可以
- 编程思想_编程有必要给孩子学吗?
- How to Identify Asynchronous I/O Bottlenecks
- Phasecraft连下两城,助力英国量子技术商业化加速!
- 国家安全机关对涉嫌危害国家安全犯罪嫌疑人杨智渊实施刑事拘传审查
- 并发程序的隐藏杀手——假共享(False Sharing)
- 第六届未来网络发展大会,即将开幕!
- 从理论到实践:MySQL性能优化和高可用架构,一次讲清
- CF1527D MEX Tree(mex&树&容斥)
- [Opportunity Enlightenment-60]: "Soldiers, Stupid Ways"-1- Opening: "Death" and "Life" are the way of heaven
猜你喜欢

Crawler - basic use of selenium, no interface browser, other uses of selenium, cookies of selenium, crawler cases

理论篇1:深度学习之----LetNet模型详解

idea去掉spark的日志

【HMS core】【Media】【视频编辑服务】 在线素材无法展示,一直Loading状态或是网络异常

Convolutional Neural Network Basics

物联网应用发展趋势

CCF GLCC officially opened | Kyushu Cloud open source experts bring generous bonuses to help universities promote open source

Lixia Action | Kyushu Yunzhang Jinnan: Open source is not a movement for a few people, popularization is the source

人像分割技术解析与应用

token 过期后,如何自动续期?
随机推荐
Almost all known protein structures in the world are open sourced by DeepMind
化算力为战力:宁夏中卫的数字化转型启示录
[in-depth study of 4 g / 5 g / 6 g project - 50] : URLLC - 16 - the 3 GPP URLLC agreement, specification, technical principle of depth interpretation - 10 - high reliability technology - 1 - low codin
手搓一个“七夕限定”,用3D Engine 5分钟实现烟花绽放效果
关于redis的几件小事(五)redis保证高并发以及高可用
小 P 周刊 Vol.13
Kyushu Cloud attended the Navigator Online Forum to discuss the current status, challenges and future of 5G MEC edge computing
Win11勒索软件防护怎么打开?Win11安全中心勒索软件防护如何设置
eyb:JWT介绍
C# 动态加载卸载 DLL
【模型部署与业务落地】基于量化芯片的损失分析
【 HMS core 】 【 Media 】 online video editing service 】 【 material can't show, or network anomalies have been Loading state
[机缘参悟-60]:《兵者,诡道也》-1-开篇:“死“与“生“都是天道
广告电商系统开发功能只订单处理
js深拷贝和浅拷贝具体使用区别_es6深拷贝和浅拷贝
电子行业MES管理系统有哪些特殊功能
中大型商业银行堡垒机升级改造就用行云管家!必看!
Centos7 install mysql version rapidly
如何才能有效、高效阅读?猿辅导建议“因材因时施教”
Qt的QItemDelegate使用