当前位置:网站首页>CF894C Marco and GCD Sequence
CF894C Marco and GCD Sequence
2022-06-10 12:56:00 【sophilex】
The question :
An interesting construction problem
I have an array , Put the... Of each interval gcd Put it in a collection , Give set , Try to restore the original sequence
Carelessness :
1. The numbers in the original sequence should all come from this set .
2. For each interval ,gcd Not greater than their minimum .
Then find the total gcd, And divide each element by this gcd, If now in the sequence 1, It means that all elements in the set can be divided by an element belonging to the set , Then we just insert a public... In front of each element gcd As the original sequence .
If there is no 1, That means our public gcd Not in this collection , Then this set is insoluble .
code:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=101000;
ll n;
ll mas[N];
vector<ll> q;
ll cnt=0;
ll sum=1;
ll gd=0;
void solve()
{
bool f=0;
for(int i=1;i<=n;++i)
{
mas[i]/=gd;
//cout<<mas[i]<<" ";
if(mas[i]==1) f=1;
}
if(!f)
{
cout<<-1;
return;
}
for(int i=1;i<=n;++i)
{
q.push_back(gd);
q.push_back(mas[i]*gd);
}
cout<<q.size()<<endl;
for(ll i:q) cout<<i<<" ";
}
int main()
{
cin>>n;
for(int i=1;i<=n;++i)
{
cin>>mas[i];
gd=__gcd(gd,mas[i]);
}
solve();
return 0;
}边栏推荐
- Asynchronous export of Excel
- 【FLinlk】Flink小坑之kerberos动态认证
- C# 均衡权重分配
- FM4057S单节锂电池线性充电芯片的学习
- 用GNN做CV三大任务的新骨干,同计算成本性能不输CNN、ViT与MLP|中科院&华为诺亚开源...
- 性能测试方案(计划)模板
- 手机厂商“返祖”,只有苹果说不
- Software project management 6.10 Cost budget
- Stereo vision based semantic 3D object and ego motion tracking for automotive driving
- Can qiniu open an account? Is it safe to open an account in qiniu
猜你喜欢

Start with interpreting the code automatically generated by BDC, and explain the trial version of the program components of sapgui

UML类图

Vdo-slam: a visual dynamic object aware slam system paper reading

H5 pop up prompt layer - top, bottom, left and right center

VDO-SLAM: A Visual Dynamic Object-aware SLAM System 论文阅读

VDMA commissioning summary

TIDB 初级课程体验 8 (集群的管理维护, 添加一个TIKV节点)

Which EDA design software should Altium Allegro pads choose

Summary of Kitti related information

微信web开发工具使用教程,公司开发web
随机推荐
excel异步导出
【Spark】(task8)SparkML中的pipeline通道建立
OFFICE技术讲座:标点符号-中文-竖排
colmap源码阅读笔记[1] threading.cc
MySQL数据库(26):视图 view
ASP.NET 利用ImageMap控件设计导航栏
Learning of cc2642r Bluetooth MCU chip
Stereo Vision-based Semantic 3D Object and Ego-motion Tracking for Autonomous Driving 论文阅读
PCB learning notes (2) -3d packaging related
Can chip learning of max3051
MySQL master database operation large table DDL, slave database crash and system parameter error setting
VDMA调试总结
【Golang】创建有配置参数的结构体时,可选参数应该怎么传?
JS converts timestamp to normal time format
Altium Allegro PADS到底该选哪个EDA设计软件
Get enumeration values through reflection
MAX3051的can芯片的学习
How can the team be dissolved...
GNN is used as the new backbone of the three major tasks of CV, with the same cost performance as CNN, Vit and MLP | Chinese Academy of Sciences & Huawei Noah open source
Colmap source code reading notes [1] threading cc