AtCoder Beginner Contest 046(4/4)

AtCoDeer and Paint Cans

找三个数的种类数

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c;
    cin >> a >> b >> c;
    set<int> se;
    se.insert(a);
    se.insert(b);
    se.insert(c);
    cout << se.size() << '\n';
    return 0;
}

Painting Balls with AtCoDeer

组合数学

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    LL ans = k;
    for (int i = 2; i <= n; i++) {
        ans = ans * (k - 1);
    }
    cout << ans << '\n';
    return 0;
}

AtCoDeer and Election Report

二人的票数每分钟都是t[i]:a[i],t[i]和a[i]互质,求最少一共多少票,则需要满足的是T<=n*t[i],A<=n*a[i],转换一下得到n>=T/t[i],n>=A/a[i],n为整数,初始T=A=1,得到n之后,就有了此时的T和A的最小值

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    LL l = 1, r = 1;
    for (int i = 0; i < n; i++) {
        LL p = max((l + a[i].first - 1) / a[i].first, (r + a[i].second - 1) / a[i].second);
        l = p * a[i].first;
        r = p * a[i].second;
    }
    cout << l + r << '\n';
    return 0;
}

AtCoDeer and Rock-Paper

布和石头游戏,布>石头,且出布的次数不能超过出石头的次数,得分为胜场数-负场数,那么最优方案就是对手出布,我也出布,对手出石头,如果我还有布我就出布

AC代码:

#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int len = s.size();
    int p = len / 2;
    for (int i = 0; i < len; i++) {
        if (s[i] == 'p') {
            p--;
        }
    }
    cout << p << '\n';
    return 0;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值