codeforces 749(Div1+2)

A. Windblume Ode

题意

A bow adorned with nameless flowers that bears the earnest hopes of an equally nameless person.

You have obtained the elegant bow known as the Windblume Ode. Inscribed in the weapon is an array of n (n≥3) positive distinct integers (i.e. different, no duplicates are allowed).

Find the largest subset (i.e. having the maximum number of elements) of this array such that its sum is a composite number. A positive integer x is called composite if there exists a positive integer y such that 1<y<x and x is divisible by y.

If there are multiple subsets with this largest size with the composite sum, you can output any of them. It can be proven that under the constraints of the problem such a non-empty subset always exists.

n个数,每个数都不同,你可以从中删除一些元素,使得总和不是素数
n(3~100)	

思路

n的个数为三,则sum>=6
考虑和为偶数时一个数都不用删
和为奇数的时候,则其中至少有一个元素为奇数
可以删除那个元素

meAC

#include <bits/stdc++.h>
using namespace std;
int arr[107];
bool isprime(int x)
{
    for (int i = 2; i * i <= x;i++)
    {
        if(x%i==0) return 0;
    }
    return 1;
}
int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int sum = 0;
        for (int i = 1; i <= n; i++)
        {
            cin >> arr[i];
            sum += arr[i];
        }
        if (isprime(sum))
        {
            cout << n - 1 << endl;
            int index1 = 1;
            while (1)
            {
                if (arr[index1] & 1)
                {
                    break;
                }
                index1++;
            }
            for (int i = 1; i <= n; i++)
            {
                if (i == index1)
                    continue;
                cout << i << " ";
            }
            cout << endl;
        }
        else
        {
            cout << n << endl;
            for (int i = 1; i <= n; i++)
                cout << i << " ";
            cout << endl;
        }
    }
}

B. Omkar and Heavenly Tree

题意

n个点,n-1条关系
关系:
a,b,c
b不能在ac最短路径上

思路

菊花图
n个点,n-1条,总有一个点是关系里面没有做过b的点

AC

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int, int>
#define psi pair<string, int>
#define ull unsigned ll
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define ld long double
const int N = 1E5 + 7;
#define INF ~0ULL
int vis[N];
int main()
{
    int t;
    cin >> t;
    int n, m;
    int a, b, c;
    while (t--)
    {
        memset(vis,0,sizeof(vis));
        cin >> n >> m;
        for (int i = 1; i <= m; i++)
        {
            cin>>a>>b>>c;
            vis[b]++;
        }
        int dex =1;
        while(1){
            if(vis[dex]==0){
                break;
            }
            dex++;
        }
        for(int i=1;i<=n;i++){
            if(i==dex) continue;
            cout<<dex<<" "<<i<<endl;
        }
    }
}

C. Omkar and Determination

链接: 大佬博客.

D. Omkar and the Meaning of Life

这是特别有意思的题

链接: link.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

.0-0.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值