“中国东信杯”广西大学第三届程序设计竞赛(同步赛)

“中国东信杯”广西大学第三届程序设计竞赛(同步赛)

A.A++++++++++++++++++

题意: 签到

题解: 取个min就完事了

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
int const MAXN = 2e5 + 10;
int n, m, T;

int main() {
   
    cin >> T;
    while(T--) {
   
        cin >> n;
        int a = 0, b = 0;
        for (int i = 1; i <= n; ++i) {
   
            string s;
            cin >> s;
            if (s == "national") a++;
            else b++;
        }
        cout << "A";
        for (int i = 0; i < min(a, b); ++i) cout << "+";
        cout << endl;
    }   
    return 0;
}

B.GDP Carry

题意: 2人博弈,a只能拿走和为奇数的段;b只能拿走和为偶数的段,不能拿就输了,问最后谁赢了

题解: 如果一开始和为奇数,a赢了;如果一开始和为偶数,且存在奇数,那么a拿走奇数,然后b拿到就是奇数,那么b拿完还是奇数。那么a拿走奇数就行了。

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
int const MAXN = 2e5 + 10;
int n, m, T;

int main() {
   
    cin >> n;
    int flg = 0;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
   
        int t;
        cin >> t;
        sum +=  t;
        if (t & 1) flg =1 ;
    }   
    if (sum % 2 == 1 || flg) cout << "Antinomy";
    else cout << "XiJam";
    return 0;
}

C.Interpretability

题意: 给定2的幂次方的个数,问最多能够组成多少个三角形

题解: 组成三角形,要不然3个一样,要不然2个一样,加上一个比它小的边。那么对于每个i,我们可以使用3个一样的,要不然使用2个一样的加上一个小的。可能会卡在这2种哪个更优先的关系上,其实可以不考虑整个。我们直接维护一个single记录到当前这个位置单个有多少个,然后维护i位置的一对的有多少个,这样取个min就知道多少个2+1的情况。剩下的许多对中可以看能不能3对组成2个。

代码:

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
int const MAXN = 4e5 + 10;
LL n, m, T, a[MAXN];

int main() {
   
    cin >> n;
    for (int i = 1; i <= n; ++i) scanf("%lld", a + i);
    LL pair = 0, single = 0, res = 0;
    LL tmp = 0, minv = 0;
    for (int i = 1; i <= n; ++i) {
   
        LL pair_cnt = a[i] / 2;
        LL single_cnt = a[i] % 2;
        tmp = pair_cnt;
        single += single_cnt;
        minv = min(pair_cnt, single);
        res += minv;
        LL cnt3 = (pair_cnt - minv) * 2 / 3;
        res += cnt3;
        single -= minv, single += (pair_cnt - minv) * 2 % 3;
    }
    cout << res;
    return 0;
}

D.Batch Normalization 1D

大意:

模拟题

思路:

大模拟题,不想做了,piao的代码

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 50;
const int INF = 0x3f3f3f3f;
const int mod = 1000000007;
LL powmod(LL a, LL b) {
    LL res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod; a = a * a % mod; } return res; }

int n, c, n_batch;
double eps, momentum;
double X[N][N];
double Gamma[N];
double Beta[N];
double moving_mean[N];
double moving_var[N];</
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值