Codeforces Round #720 (Div. 2) ABCDE题解
Posted quinn18
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #720 (Div. 2) ABCDE题解相关的知识,希望对你有一定的参考价值。
目录
A - Nastia and nearly Good Numbers
题目链接
构造
题意:给你
A
,
B
A, B
A,B 输出
x
,
y
,
z
x, y, z
x,y,z, 满足
x
+
y
=
z
x+y=z
x+y=z, 两个个只能被A整除,一个能被A*B整除
#include<bits/stdc++.h>
using namespace std;
const int N=15;
const int M=1e9+7;
#define ll long long
ll t, n, l, r, sum, cnt, q, a[N];
string s;
int main(){
cin>>t;
while(t--){
cin>>l>>r;
if(r==1) cout<<"NO"<<endl;
else {
cout<<"YES"<<endl;
cout<<(r-1)*l<<" "<<(r+1)*l<<" "<<(2*r)*l<<endl;
}
}
return 0;
}
B - Ordinary Numbers
tmlj
构造
题意 :最多
n
n
n次修改随便两个数,使数列中相邻两个数gcd为1 修改条件是你选中的两个数
m
i
n
(
a
i
,
a
j
)
=
=
m
i
n
(
x
,
y
)
,
a
i
=
x
,
a
j
=
y
。
min(ai, aj)==min(x, y), ai=x, aj=y。
min(ai,aj)==min(x,y),ai=x,aj=y。
找最小的数 往两边扩展开来一直
+
1
+
1
+
1
+1+1+1
+1+1+1 毕竟相邻的数字肯定是互质的
就一直拿这个最小的数拿来和别人交换
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
const int M=1e9+7;
#define ll long long
ll t, n, l, r, sum, cnt, q, a[N], minn;
string s;
int main(){
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin>>t;
while(t--){
cin>>n;
minn=1e18;;
for(int i=1; i<=n; i++) {
cin>>a[i];
if(a[i]<minn) {
minn=a[i];
q=i;//找最小值
}
}
cout<<n-1<<endl;
for(int i=1; i<=n; i++) {
if(i==q) continue;
if(i<q)cout<<i<<" "<<q<<" "<<q-i+minn<<" "<<minn<<endl;
else cout<<i<<" "<<q<<" "<<i-q+minn<<" "<<minn<<endl;
}
}
return 0;
}
C - Nastia and a Hidden Permutation
题目链接
构造 交互
题意 :通过一直问最大值和最小值去确定一个
1
−
n
1-n
1−n的数列 查询次数
(
3
/
2
)
n
(3/2)n
(3/2)n次
t
1
t1
t1找两数最大值
t
2
t2
t2找两数最小值
最讨厌交互了
被理A了也写不来
就假设数据非常友好 你两个数两个数
t
1
t1
t1找他们之间的最大值 一直找找到了
n
n
n, 花了
n
/
2
n/2
n/2次,你就确定了
n
n
n的位置,然后遍历一遍用
t
2
t2
t2找其他位置的数 花
n
−
1
n-1
n−1次 然后还有很多特判。。。不懂
D - Nastia Plays with a Tree
题目链接
不管 它也是构造
题意 :把一课树通过最少次数拆掉连起来变成一条长链 输出 拆的节点和连的节点
啊赛后又被理A了本来还以为是dp呢
找树的直径 然后一直把某个节点深度长的接在末尾上 就贪心dfs一下
总结
没什么错就不要重交了= =
交易前看看题目要求输出什么 wa1是怎么回事。。。啊原来wa1不扣分
以上是关于Codeforces Round #720 (Div. 2) ABCDE题解的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #720 (Div. 2)Codeforces-1521ABC
Codeforces Round #720 (Div. 2) ABCDE题解
Codeforces Round #720 (div2) AB
Codeforces Round #720 (Div. 2), B. Nastia and a Good Array
Codeforces Round #720 (Div. 2) A. Nastia and Nearly Good Num