当前位置:网站首页>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;
}
边栏推荐
- 人像分割技术解析与应用
- 编程思想_编程有必要给孩子学吗?
- Centos7 install mysql version rapidly
- CF1527D MEX Tree (mex & tree & inclusive)
- Lixia Action | Kyushu Yunzhang Jinnan: Open source is not a movement for a few people, popularization is the source
- ssm学习心得(完结篇
- FreeConfig.h文件
- MPLS experiment
- 快解析结合友加畅捷U+
- How to find the location of a pdf file in endnote literature
猜你喜欢
随机推荐
odoo15 大部分模块都用的附件整理成一独立模块
Set partition minimum difference problem (01 knapsack)
token 过期后,如何自动续期?
NPDP|作为产品经理,如何快速提升自身业务素养?
SMART S7-200PLC串行自由口通讯(耐压测试仪)
【模型部署与业务落地】基于量化芯片的损失分析
浙江大学团队使用基于知识图谱的新方法,从空间分辨转录组数据中推断细胞间通信状况
第六届未来网络发展大会,即将开幕!
Redis 复习计划 - Redis主从数据一致性和哨兵机制
"C pitfalls and pitfalls" reading summary
广告电商系统开发功能只订单处理
centos7安装mysql急速版
The Internet of things application development trend
物联网应用发展趋势
Crawler - action chain, xpath, coding platform use
文盘Rust -- 配置文件解析
C# winforms 输入颜色转换颜色名
Convolutional Neural Network Basics
[深入研究4G/5G/6G专题-50]: URLLC-16-《3GPP URLLC相关协议、规范、技术原理深度解读》-10-高可靠性技术-1-低编码率编码调制方案MCS与高可靠性DRB
手搓一个“七夕限定”,用3D Engine 5分钟实现烟花绽放效果









