CodeForces 621A Wet Shark and Odd and Even

水题

#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<vector>
#include<algorithm>
using namespace std;

int n;
long long a[100000+10];

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    sort(a,a+n);

    long long ans1=0,ans2=0,num=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]%2==0) ans1=ans1+a[i];
        else ans2=ans2+a[i],num++;
    }
    if(num%2==0) printf("%lld\n",ans1+ans2);
    else
    {
        for(int i=0;i<n;i++)
            if(a[i]%2==1)
                {ans2=ans2-a[i];break;}
        printf("%lld\n",ans1+ans2);
    }
    return 0;
}
时间: 2024-10-13 23:58:34

CodeForces 621A Wet Shark and Odd and Even的相关文章

【CodeForces 621A】Wet Shark and Odd and Even

题 Today, Wet Shark is given n integers. Using any of these integers no more than once, Wet Shark wants to get maximum possible even (divisible by 2) sum. Please, calculate this value for Wet Shark. Note, that if Wet Shark uses no integers from the n 

Codeforces Round #341 Div.2 A. Wet Shark and Odd and Even

题意是得到最大的偶数和 解决办法很简单 排个序 取和 如果是奇数就减去最小的奇数 #include <cstdio> #include <cmath> #include <cstring> #include <queue> #include <vector> #include <algorithm> #define INF 0x3f3f3f3f #define mem(str,x) memset(str,(x),sizeof(str)

CodeForces 621C Wet Shark and Flowers

方法可以转化一下,先计算每一个鲨鱼在自己范围内的数能被所给素数整除的个数有几个,从而得到能被整除的概率,设为f1,不能被整除的概率设为f2. 然后计算每相邻两只鲨鱼能获得钱的期望概率,f=w[id1].f1*w[id2].f2+w[id1].f2*w[id2].f1+w[id1].f1*w[id2].f1; f*2000就是这两只鲨鱼能获得的期望金钱,然后枚举一下所有相邻的鲨鱼,累加即可. #include<cstdio> #include<cstring> #include<

CodeForces 621B Wet Shark and Bishops

记录一下每个对角线上有几个,然后就可以算了 #include<cstdio> #include<cstring> #include<cmath> #include<ctime> #include<vector> #include<algorithm> using namespace std; const int maxn=2000+10; int n; long long w1[maxn]; long long w2[maxn]; l

【CodeForces 621C】Wet Shark and Flowers

题 There are n sharks who grow flowers for Wet Shark. They are all sitting around the table, such that sharks i andi + 1 are neighbours for all i from 1 to n - 1. Sharks n and 1 are neighbours too. Each shark will grow some number of flowers si. For i

矩阵乘法&amp;&amp;dp加速矩阵的思路(E. Wet Shark and Blocks)

There are b blocks of digits. Each one consisting of the same n digits, which are given to you in the input. Wet Shark must choose exactly one digit from each block and concatenate all of those digits together to form one large integer. For example,

Wet Shark and Bishops(思维)

Today, Wet Shark is given n bishops on a 1000 by 1000 grid. Both rows and columns of the grid are numbered from 1 to 1000. Rows are numbered from top to bottom, while columns are numbered from left to right. Wet Shark thinks that two bishops attack e

【CodeForces 621B】Wet Shark and Bishops

题 题意 1000*1000的格子里,给你n≤200 000个点的坐标,求有多少对在一个对角线上. 分析 如果求每个点有几个共对角线的点,会超时. 考虑到对角线总共就主对角线1999条+副对角线1999条,我们可以求每个对角线有几对点. 同一条主对角线上的元素有a[i]个,就有C(a[i],2)对点: 同一条副对角线上的元素有b[i]个,就有C(b[i],2)对点. 读入x和y后, x+y相同的就在同一副对角线,x+y范围是(2,2000), x-y相同的就是同一主对角线,x-y范围是(-999

Codeforces Round #341 Div.2 C. Wet Shark and Flowers

题意: 不概括了..太长了.. 额第一次做这种问题 算是概率dp吗? 保存前缀项中第一个和最后一个的概率 然后每添加新的一项 就解除前缀和第一项和最后一项的关系 并添加新的一项和保存的两项的关系 这里关系指的是两者相邻会产生的额外收入(其中一个满足条件就能得到 因此公式是 2000 * (rate[a] * rate[b] + rate[a] * ( 1 - rate[b]) + rate[b] * (1 - rate[a])) 至于一开始为什么老是调不过去呢..我发现添加第三项的时候前两项是不