关于 J 题 (n+1)(n+1)/6 >= k 解法的疑问
这里有几组数据
test #1:
58 5813
good:
no
187
bad:
no
186
test #2:
79 8569
good:
no
227
bad:
no
226
test #3:
69 9828
good:
no
243
bad:
no
242
我用的产生 good
输出的代码是下面这份,也就是相当于把一对情侣扩张成 2 x 3
放置
#include <bits/stdc++.h>
using i64 = int64_t;
using u64 = uint64_t;
using f64 = double_t;
using i128 = __int128_t;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout << std::fixed << std::setprecision(12);
int n, k;
std::cin >> n >> k;
for (int L = 1; ; L++) {
int r = L % 3;
int tot = (L + 1) / 2 * (L / 3 + r - 1) + L / 3 * (2 - r) + (r == 1 and L % 4 == 0);
if (tot >= k) {
if (L <= n) {
std::cout << "yes\n";
} else {
std::cout << "no\n";
std::cout << L << "\n";
}
return 0;
}
}
return 0;
}
我用的产生 bad
输出的代码是下面这份,也就是 的解法
#include <bits/stdc++.h>
using i64 = int64_t;
using u64 = uint64_t;
using f64 = double_t;
using i128 = __int128_t;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cout << std::fixed << std::setprecision(12);
int n, k;
std::cin >> n >> k;
if ((n + 1) * (n + 1) / 6 >= k) {
std::cout << "yes\n";
} else {
std::cout << "no\n";
std::cout << int(std::sqrt(6 * k - 1)) << "\n";
}
return 0;
}
我感觉下面这个解法是有点问题的,大伙怎么看,或者说有没有可能 good
的解法才是有问题的? 😰