Codeforces Round 964 (Div. 4)全部题解

A. A+B Again?

题目大意

给定n求数位和。

思路

代码实现
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define Mod 998244353
#define PI acos(-1);
#define MAXN 210000
#define debug cout<<"debug:\t"
#define debugn cout<<"debug:\n"
#define enter cout<<"\n"
void fastread() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
};
void solve() {
    ll n; cin >> n;
    ll ans = 0;
    while (n) {
        ans += n % 10;
        n /= 10;
    }
    cout << ans << "\n";
}
int main() {
    //fastread();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t = 1;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

B. Card Game

题目大意

Su,Sl两个人做游戏,问Su胜利的所有局内,胜利的回合数。

注意,比赛顺序不同视为不同答案。

思路

注意题意即可。

代码实现
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define Mod 998244353
#define PI acos(-1);
#define MAXN 210000
#define debug cout<<"debug:\t"
#define debugn cout<<"debug:\n"
#define enter cout<<"\n"
void fastread() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
};
void solve() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = 0;
    if (a > c && b > d)ans+=2;
    if (a > d && b > c)ans+=2;
    if (a > c && b == d)ans += 2;
    if (a > d && b == c)ans += 2;
    if (a == c && b > d)ans += 2;
    if (a == d && b > c)ans += 2;
    cout << ans << "\n";
}
int main() {
    //fastread();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t = 1;
    cin >&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值