目录
题目
A. Difference Operations
题意:
给你个长度为n的序列, 每次你可以选一个i (范围2~n), 使得, 可以进行任意次操作, 问最后能不能让从2~n的ai都为0
思路:
开始想着是等差数列, 但后来发现是等比, 检验是不是等比数列就行, 证明我也不会, 口胡出的做法
code:
/**
* author: CurleyD
* created: 07.16.2022 22:35:32
**/
#include <bits/stdc++.h>
#define endl '\n'
#define IO ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
typedef long long LL;
//#define LOCAL
//#define int LL
//head
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
int T, n, m;
void solve() {
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 2; i <= n; i++)
if (a[i] % a[1] != 0) {
cout << "NO\n";
return;
}
cout << "YES\n";
}
signed main() {
IO;
#ifdef LOCAL
freopen("out.txt","w",stdout);
#endif
cin >> T;
while(T--) {solve();}
return 0;
}
B.Difference of GCDs
题意:
给你 n, l, r. 让你输出从1~n, 使得每个都不同的
.
思路:
赛时就想到一定是让 每个的gcd都等于i, 即gcd(i,ai) = i, 构造时候两种情况
1)ai不能整除i
2)ai能够整除i
对于每个ai来说都是由来构造的, 得解
没实现出来, 数学很垃圾
code:
/**
* author: CurleyD
* created: 07.16.2022 23:32:08
**/
#include <bits/stdc++.h>
#define endl '\n'
#define IO ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
typedef long long LL;
//#define LOCAL
//#define int LL
//head
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
int T, n, m;
int l, r;
int gcd(int a, int b) {
return b ? gcd(b, a % b) : a;
}
void solve() {
cin >> n >> l >> r;
vector<int> res;
for (int i = 1; i <= n; i++) {
int t = i * (l / i + 1);
if (l % i == 0) {
res.push_back(l);
}
else if (t <= r && t >= l) {
res.push_back(t);
}
else {
cout << "NO\n";
return;
}
}
int cnt=1;
cout << "YES\n";
for (auto x : res)
cout << x << " ";
cout << endl;
}
signed main() {
IO;
#ifdef LOCAL
freopen("out.txt","w",stdout);
#endif
cin >> T;
while(T--) {solve();}
return 0;
}
C.Doremy's IQ
题意:
给你竞赛总个数n, 你当前的智商q, 以及对应的竞赛序列, 在你智商大于等于零的前提下
每次 1)如果你当前智商<竞赛所需要智商, 那么智商-1, 输出1, 2)你当前智商>所需, 输出1
3)小于需要的, 且为0 输出0.
问你最多输出1的个数
思路:
也是构造, 正难则反, 既然顺着推过去不一定是最优的, 那我们可以反过来? 不会证明,仅仅理解了皮毛...
code:
/**
* author: CurleyD
* created: 07.17.2022 05:51:12
**/
#include <bits/stdc++.h>
#define endl '\n'
#define IO ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
typedef long long LL;
//#define LOCAL
//#define int LL
//head
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
int T, n, m, q;
void solve() {
cin >> n >> q;
vector<int> a(n + 1);
vector<int> res(n + 1);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int cur = 0;
for (int i = n; i >= 1; i--) {
if (cur < a[i]) {
if (cur < q) {
cur ++;
res[i] = 1;
}
}
else {
res[i] = 1;
}
}
for (int i = 1; i <= n; i++)
cout << res[i];
cout << endl;
}
signed main() {
IO;
#ifdef LOCAL
freopen("out.txt","w",stdout);
#endif
cin >> T;
while(T--) {solve();}
return 0;
}
总结:
1)实力菜, 遇到数学完全不会推, 这场只出了A, 而且是WA疯了才过.
2)以后推式子不能只要结论, 过程也是对以后推类似的式子的积累, 要重视推导.
3)做CF不能只想着怎么过题, 而忘记了CF是用来检验自己的, 感觉CF上分不是你会了多少算法, 而是你构造题/结论题/推式子/实现的速度而已, 打比赛可能不太会涉及到, 还是稳扎稳打学算法, 打CF当作消遣. 这段时间没怎么学新的算法, 一直瞎**, 需要潜心修炼下, 抓住假期的好时间, 提升自己, 少点功利心, 别以rating当作自己的实力, 自己现在打cf出的题都是那些最简单的思维题, 根本检验不了自己, 不bb了, 以后要多学, 精学, 学透, 学懂...

被折叠的 条评论
为什么被折叠?



