Codeforces Round #292 (Div. 2)

本文深入探讨了算法应用与编程技巧,包括数据结构、算法、软件开发等核心内容,通过实例解析,帮助开发者掌握关键技能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

A. Drazil and Date

无算法,判断(s - (a + b)) % 2是否为零,若零,表示在s步内还能走向其他的地方并且回来
否则,都是No

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <set>
using namespace std;

const int MAXN = 1e6 + 10;
const int INF = 0x3f3f3f3f;

int main(void)
{
    //freopen ("A.in", "r", stdin);
    
    long long a, b, s;
    
    while (~scanf ("%I64d%I64d%I64d", &a, &b, &s))
    {
        if (a < 0)  a = -a;
        if (b < 0)  b = -b;
        if (a + b <= s)
        {
            int x = s - (a + b);
            if (x % 2 == 0) puts ("Yes");
            else    puts ("No");
        }
        else    puts ("No");
    }
    
    return 0;
}

B. Drazil and His Happy Friends

无算法,标记和更新happy的人就行了
少写一个&!,导致runtime error

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <set>
using namespace std;

const int MAXN = 1e6 + 10;
const int INF = 0x3f3f3f3f;
int a[110], b[110];

int main(void)
{
    //freopen ("B.in", "r", stdin);
    
    int n, m;
    scanf ("%d%d", &n, &m);
    
    memset (a, 0, sizeof (a));
    memset (b, 0, sizeof (b));
    
    int x, y, tmp, cnt = 0;
    scanf ("%d", &x);
    for (int i=0; i<x; ++i)
    {
        scanf ("%d", &tmp);
        a[tmp] = 1;
        cnt++;
    }
    scanf ("%d", &y);
    for (int i=0; i<y; ++i)
    {
        scanf ("%d", &tmp);
        b[tmp] = 1;
        cnt++;
    }
    
    for (int i=0; i<=m*n*2; ++i)
    {
        if (a[i%n] || b[i%m])
        {
            if (!a[i%n])    cnt++;
            if (!b[i%m])    cnt++;
            a[i%n] = b[i%m] = 1;
        }
    }
    (cnt == n + m) ? puts ("Yes") : puts ("No");
    
    return 0;
}

C. Drazil and Factorial

无算法,数学问题貌似就是对单个数字分解质因数,替换,然后sort排序就行了

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <set>
using namespace std;

const int MAXN = 1e6 + 10;
const int INF = 0x3f3f3f3f;

string res[10] = {"", "", "2", "3", "322", "5", "53", "7", "7222", "7332"};

int main(void)
{
    //freopen ("C.in", "r", stdin);
    
    int n;
    while (cin >> n)
    {
        string s, ans;
        cin >> s;
        for (int i=0; i<s.size(); ++i)
        {
            ans += res[s[i] - '0'];
        }
        sort (ans.begin (), ans.end ());
        reverse (ans.begin (), ans.end ());
        
        cout << ans << endl;
    }
    
    return 0;
}

 

转载于:https://www.cnblogs.com/Running-Time/p/4366760.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值