题库首页 › 信息学奥赛 › 题目 17730

阅读程序(二) 7-13题 组合题 include include include 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) { 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; } --ti; if (ti == 0) { assert_ans(n); return; } } } int main() { scanf("%d%d", &n, &k); int t; scanf("%d", &t); if (t == 1) { guess1(n); } else { guess2(n); } return 0; }

正确答案:判断题答案A。输入6 5 1时猜测5次、6 5 2时猜测3次,正确。

试卷来源:2025 CSP-S提高级(第一轮)C++真题

本卷相关题目

在线做题 同科目题库