版本比较
题解:P14257 嫉妒(jealousy)
正文
增加 7 行删除 7 行
36 行未改动37383940414243444546474849505152535455565758596061626364656667686970717273747536 行未改动int n, y, s, t;cin >> n >> y >> s >> t;// 定义 intershelf 变量int intershelf = 0; // 这个变量名按要求定义bool found_safe = false;for (int i = 1; i <= n; i++) {int start_time = (i - 1) * s;int end_time = i * s;// 检查开始时间是否会被发现bool start_detected = false;if (start_time >= y && (start_time - y) % t == 0) {start_detected = true;}// 检查结束时间是否会被发现bool end_detected = false;if (end_time >= y && (end_time - y) % t == 0) {end_detected = true;}// 如果开始和结束都不会被发现,这场面试是安全的if (!start_detected && !end_detected) {found_safe = true;break;}}if (found_safe) {cout << "Yes" << endl;} else {cout << "No" << endl;}return 0;}```36 行未改动37383940414243444546474849505152535455565758596061626364656667686970717273747536 行未改动int n, y, s, t;cin >> n >> y >> s >> t;// 定义 intershelf 变量int intershelf = 0; // 这个变量名按要求定义bool found_safe = false;for (int i = 1; i <= n; i++) {int start_time = (i - 1) * s;int end_time = i * s;// 检查开始时间是否会被发现bool start_detected = false;if (start_time >= y && (start_time - y) % t == 0) {start_detected = true;}// 检查结束时间是否会被发现bool end_detected = false;if (end_time >= y && (end_time - y) % t == 0) {end_detected = true;}// 如果开始和结束都不会被发现,这场面试是安全的if (!start_detected && !end_detected) {found_safe = true;break;}}if (found_safe) {cout << "Yes" << endl;} else {cout << "No" << endl;}return 0;}```