慕慕慕团队竞赛代码展示第一届第四名
2025-12-05 21:50:51
发布于:浙江
注:检查人员不记入排名
首届“慕慕慕”团队编程竞赛初赛
第四名怀疑ai
T1代码:
#include <stdio.h>
int main() {
int x, y, z;
// 读取输入数据
scanf("%d %d %d", &x, &y, &z);
// 判断第z天小明是否去超市(每5天一次)
int ming_visit = (z - x) % 5;
// 判断第z天小白是否去超市(每7天一次)
int bai_visit = (z - y) % 7;
// 如果两人都去超市(余数都为0),则相遇
if (ming_visit == 0 && bai_visit == 0) {
printf("Yes\n");
} else {
printf("No\n");
}
return 0;
}
T2代码:
#include <stdio.h>
int main() {
long long n;
scanf("%lld", &n);
long long count = 0;
// 优化:根据方程组推导,减少循环范围
// 设公鸡x只,母鸡y只,小鸡z只
// 方程组:x + y + z = n 且 5x + 3y + z/3 = n
// 化简得:7x + 4y = n
// 所以 x 的范围是 0 到 n/7
for (long long x = 0; x <= n / 7; x++) {
// 计算 y = (n - 7*x) / 4
long long remainder = n - 7 * x;
if (remainder >= 0 && remainder % 4 == 0) {
long long y = remainder / 4;
long long z = n - x - y;
// 验证条件:z必须是非负整数,且是3的倍数(因为小鸡3只1元)
if (z >= 0 && z % 3 == 0) {
// 验证价格:5x + 3y + z/3 == n
if (5 * x + 3 * y + z / 3 == n) {
count++;
}
}
}
}
printf("%lld\n", count);
return 0;
}
T3代码:
#include <stdio.h>
int main() {
char ch;
scanf("%c", &ch);
// 直接判断字符ASCII值的奇偶性
if (ch % 2 == 1) {
printf("YES\n");
} else {
printf("NO\n");
}
return 0;
}
T4代码:
#include <iostream>
#include <cmath>
using namespace std;
long long solve(long long n, long long m) {
long long d = abs(m - n);
if (d == 0) return 0;
long long k = sqrt(2 * d);
while (k * (k + 1) / 2 < d) {
k++;
}
long long sum = k * (k + 1) / 2;
if ((sum - d) % 2 == 0) {
return k;
} else {
if (k % 2 == 0) {
return k + 1;
} else {
return k + 2;
}
}
}
int main() {
int t;
cin >> t;
while (t--) {
long long n, m;
cin >> n >> m;
cout << solve(n, m) << endl;
}
return 0;
}
T5代码:
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main() {
string str;
getline(cin, str);
for (char &c : str) {
if (isupper(c)) {
c = tolower(c);
} else if (islower(c)) {
c = toupper(c);
}
}
cout << str << endl;
return 0;
}
T6代码:
#include <iostream>
using namespace std;
int main() {
int k;
cin >> k;
int total_coins = 0;
int current_day = 0;
int current_coins = 1;
// 模拟金币发放过程
while (current_day < k) {
// 连续 current_coins 天每天发放 current_coins 枚金币
int days_in_this_group = min(current_coins, k - current_day);
total_coins += days_in_this_group * current_coins;
current_day += days_in_this_group;
current_coins++;
}
cout << total_coins << endl;
return 0;
}
T7代码:
#include <iostream>
#include <vector>
using namespace std;
int main() {
int l, m;
cin >> l >> m;
// 创建一个标记数组,表示每个位置是否有树
// 初始时所有位置都有树(true表示有树)
vector<bool> trees(l + 1, true);
// 处理每个地铁区域
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
// 将区间[u, v]内的树标记为移除
for (int j = u; j <= v; j++) {
trees[j] = false;
}
}
// 统计剩余的树木数量
int count = 0;
for (int i = 0; i <= l; i++) {
if (trees[i]) {
count++;
}
}
cout << count << endl;
return 0;
}
T8代码:
#include <stdio.h>
int main() {
int apples[10];
int height;
int count = 0;
// 读取10个苹果的高度
for (int i = 0; i < 10; i++) {
scanf("%d", &apples[i]);
}
// 读取陶陶的手臂伸直高度
scanf("%d", &height);
// 计算陶陶站在板凳上能够达到的总高度
int total_height = height + 30;
// 统计能够摘到的苹果数量
for (int i = 0; i < 10; i++) {
if (apples[i] <= total_height) {
count++;
}
}
// 输出结果
printf("%d\n", count);
return 0;
}
T9代码:
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n == 0) {
printf("0\n");
return 0;
}
int reversed = 0;
int temp = n;
// 处理负数
if (temp < 0) {
temp = -temp; // 转为正数处理
}
// 反转数字
while (temp > 0) {
reversed = reversed * 10 + temp % 10;
temp /= 10;
}
// 如果是负数,添加负号
if (n < 0) {
reversed = -reversed;
}
printf("%d\n", reversed);
return 0;
}
T10代码:
#include <iostream>
using namespace std;
int main() {
int k;
cin >> k;
double sum = 0.0;
int n = 0;
while (sum <= k) {
n++;
sum += 1.0 / n;
}
cout << n << endl;
return 0;
}
全部评论 1
我是检查员,用AI没问题吧
1周前 来自 湖南
0666
1周前 来自 上海
0检查员自己用AI,知法犯法是吧(bushi

1周前 来自 上海
0拿杂乐(那咋了)
1周前 来自 湖南
0














有帮助,赞一个