YOU HAVE NO EGG!
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
#include <algorithm>
#include <cstdio>
#include <cstring>
#define ll long long
int cnt_broken = 0;
int cnt_check = 0;
int n, k;
inline bool check(int h) {
printf("now check:%d\n", h);
++cnt_check;
if (cnt_broken == 2) {
printf("You have no egg!\n");
return false;
}
if (h >= k) {
++cnt_broken;
return true;
} else {
return false;
}
}
inline bool assert_ans(int h) {
if (h == k) {
printf("You are Right using %d checks\n", cnt_check);
return true;
} else {
printf("Wrong answer!\n");
return false;
}
}
inline void guess1(int n) {
for (int i = 1; i <= n; ++i) {
if (check(i)) {
assert_ans(i);
return;
}
}
}
inline void guess2(int n) {
int w = 0;
for (w = 1; w * (w + 1) / 2 < n; ++w);
for (int ti = w, nh = w;; --ti, nh += ti, nh = std::min(nh, n)) {
if (check(nh)) {
for (int j = nh - ti + 1; j < nh; ++j) {
if (check(j)) {
assert_ans(j);
return;
}
}
assert_ans(nh);
return;
}
}
}
int main() {
scanf("%d%d", &n, &k);
int t;
scanf("%d", &t);
if (t == 1) {
guess1(n);
} else {
guess2(n);
}
return 0;
}
- 该程序check函数最大的作用为?( ) {{ select(1) }}
- 尝试是否符合条件
- 体检
- 骂人
- 让你碎成小可
- 为什么程序用egg? {{ select(2) }}
- 鸡蛋易碎,作为题目道具更好理解
- 鸡蛋是圆的
- CCF想创造小可帝国
- CCF出题人嫉妒了
- guess1和guess2最大的区别是?( ){{ select(3) }}
- 时间复杂度不同
- 名称不一样
- guess1更直观,guess2更神经
- guess1的折磨比较漫长,一直砸你。guess2痛快一些
- 为什么输出
You have no egg!的条件是cnt_broken == 2?( ){{ select(4) }}
- 因为题目设定
- 因为CCF比较2
- 因为一般人只有两个
- 因为他善~~~
- 这个程序是谁写的?( ){{ select(5) }}
- 人类
- 非人哉
- 我
- 洒A洒B!