随笔分类 - OJ
摘要:A - From Hero to Zero 模拟。 能除 \(k\) 直接除 \(k\),否则减掉余数部分。 点击查看代码 #include <bits/stdc++.h> using i64 = long long; void solve() { i64 n, k; std::cin >> n >
阅读全文
摘要:A - MEX Partition 思维? 求 \(a\) 的 \(\text{mex}\)。 关于证明,参考官方题解: 首先,让 \(m=\operatorname{mex}(A)\) 。我们可以忽略所有大于 \(m\) 的元素。这是因为由于 \(m\) 是 mex, \(m\) 不会出现在 \(
阅读全文
摘要:A. Circle of Apple Trees 模拟。 可以一直循环,那么将原数组去重排序后,第 \(i\) 轮吃第 \(i\) 个就可以把所有不同的数字都吃掉,即答案就是去重后的元素个数。 点击查看代码 #include <bits/stdc++.h> using namespace std;
阅读全文
摘要:A - El fucho 模拟。 胜者组共有 \(n-1\) 队进入败者组,进入败者组的会淘汰 \(n-2\) 队,最后剩两组再进行一场,总场数 \(2n-2\)。 不会算也可以直接模拟。 点击查看代码 #include <bits/stdc++.h> using i64 = long long;
阅读全文
摘要:A - Candies for Nephews 模拟。 看 \(3\) 的余数。 点击查看代码 #include <bits/stdc++.h> using namespace std; using i64 = long long; void solve() { int n; std::cin >>
阅读全文
摘要:A - Increase or Smash 模拟。 对于每个不是最大值的来说,都会经历一次先置为零然后再加的操作,重复项只计算一次;而最大值不用置为零,所以最开始会有一次。 点击查看代码 #include <bits/stdc++.h> using namespace std; using i64
阅读全文
摘要:A. Be Positive 模拟。 只需要把负数和零变为正即可。 点击查看代码 #include <bits/stdc++.h> using namespace std; using i64 = long long; void solve() { int n; cin >> n; int cnt[
阅读全文
摘要:A - Shortest Increasing Path 思维。 当 \(y>x\) 时,可以走 \(x\rightarrow y\) 两步即可;\(x \ge y + 2\) 时,可以走 \(1 \rightarrow y \rightarrow x - 1\) 三步即可,其余无解。 点击查看代码
阅读全文
摘要:A. Incremental Subarray 思维,观察。 把它那个数字表打出来观察,会发现如果给的 \(a\) 不是一段连续的区间,只会出现一次;否则看 \(a_m\),那么答案就是 \(\sum_{i=1}^n[i\ge a_m]=n-a_m+1\)。 点击查看代码 #include <bit
阅读全文

浙公网安备 33010602011771号