2025年第八届广西大学生程序设计大赛(正式赛)题解(更新中)

请添加图片描述

知乎评价:如何评价2025年第八届GXCPC广西大学生程序设计大赛暨中国-东盟国际大学生程序设计大赛?

榜单:牛客比赛排名

题目链接:第八届广西大学生程序设计大赛暨2025邀请赛

TIP:提交处可查看别人过题代码

难度签到题普通题中等题难题
题号A D HBE G J K LC F I
情况--

全部资料:一至八届 GXCPC广西大学生程序设计竞赛 题目与题解


签到题

A. Additive Combinatorics

A. Additive Combinatorics

加性组合

题目大意:

判断 C 是否是 A 和 B 的和集

解题思路:

官方题解PPT还没看到

博主补充:

双重循环,计算每一对元素的和,将和存入集合(集合会自动排序和去重)

参考代码c++:

#include<bits/stdc++.h>
using namespace std;

int main() {
    int n1, n2, n3, x;
    cin >> n1 >> n2 >> n3;
    
    vector<int> a(n1), b(n2);
    for (int &x : a) cin >> x;
    for (int &x : b) cin >> x;
    
    set<int> c;
    while (n3--) cin >> x, c.insert(x);
    
    set<int> temp;
    for (int i : a) for (int j : b) temp.insert(i + j);
    
    cout << (temp == c ? "YES" : "NO");
}

D. DeepSeek, DeepThink!

D. DeepSeek, DeepThink!

深度求索,深度思考!

题目大意:

修改输入的值(开头首字母改小写,末尾?改.),前面拼接一段值,最后输出

解题思路:

官方题解PPT还没看到

博主补充:

没啥好说的,字符串处理方式多种多样

参考代码c++:

#include<bits/stdc++.h>
using namespace std;

int main() {
    string s;
    getline(cin, s);
    s.front() = tolower(s.front());
    s.back() = '.';
    cout << "Okay, so I want to figure out " << s;
}

H. Hollow Knight: Silksong

H. Hollow Knight: Silksong

空洞骑士:丝之歌

题目大意:

其实就是,计算还有多少天发布游戏

解题思路:

官方题解PPT还没看到

博主补充:

想简化代码有很多种方式,闰年计算可以简化,

参考代码c++:

#include <iostream>
using namespace std;

bool is_leap(int year) {
    return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}

int main() {
    int y, m, d;
    cin >> y >> m >> d;
    const int end_days = 261; // 2025-09-18是当年的第261天
    int total = 0;
    
    // 计算起始日期在当年的天数
    int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    if (is_leap(y)) days[2] = 29;
    int start = d;
    for (int i = 1; i < m; ++i) start += days[i];
    
    if (y == 2025) {
        total = end_days - start;
    } else {
        total = (is_leap(y) ? 366 : 365) - start; // 剩余天数
        for (int yr = y + 1; yr < 2025; ++yr) {  // 中间年份
            total += is_leap(yr) ? 366 : 365;
        }
        total += end_days; // 加上2025年的天数
    }
    cout << total << endl;
    return 0;
}

普通题

B. Beats

B. Beats

节拍

题目大意:

每个节拍开始的瞬间,不能有某个音符正在播放但还没有结束

解题思路:

官方题解PPT还没看到

博主补充:

记录前缀和,然后循环里判断(前缀和的写法可以优化)

参考代码c++:

#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,a[200010],s[200010];
map<int,bool>m;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i],s[i]=s[i-1]+a[i],m[s[i]]=1;
	for(int i=1;i<=n;i++){
		int k=s[i];
		for(int j=2;;j++){
			if(k*j>=s[n]){
				cout<<k;
				return 0;
			}
			if(!m.count(k*j))break;
		}
	}
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值