HDU 5744 ( Keep On Movin )

来源:互联网 发布:访客网络连不上 编辑:程序博客网 时间:2024/05/24 05:48

题解:水题 把奇数拆分成1和偶数 看偶数能平均给每个1分多少的长度就可以了


#include <iostream>#include <cstring>using namespace std;const int maxn = 1e5 + 10;int main(){    int t;    scanf("%d", &t);    while(t--)    {        int n;        long long jishu = 0, oushu = 0;        scanf("%d", &n);        for(int i = 0; i < n; i++){            int tmp;            scanf("%d", &tmp);            if(tmp & 1){                jishu += 1;                oushu += tmp - 1;            }            else                oushu += tmp;        }        if(jishu == 0)            printf("%lld\n", oushu);        else            printf("%lld\n", 1 + ((oushu / 2) / jishu) * 2);            }    return 0;}


0 0
原创粉丝点击