HDU-5835-Danganronpa【2016CCPC网络赛】

原创 2016年08月30日 11:19:47

1004-Danganronpa


Problem Description
Chisa Yukizome works as a teacher in the school. She prepares many gifts, which consist of n kinds with a[i] quantities of each kind, for her students and wants to hold a class meeting. Because of the busy work, she gives her gifts to the monitor, Chiaki Nanami. Due to the strange design of the school, the students’ desks are in a row. Chiaki Nanami wants to arrange gifts like this:

  1. Each table will be prepared for a mysterious gift and an ordinary gift.

  2. In order to reflect the Chisa Yukizome’s generosity, the kinds of the ordinary gift on the adjacent table must be different.

  3. There are no limits for the mysterious gift.

  4. The gift must be placed continuously.

She wants to know how many students can get gifts in accordance with her idea at most (Suppose the number of students are infinite). As the most important people of her, you are easy to solve it, aren’t you?

Input
The first line of input contains an integer T(T≤10) indicating the number of test cases.

Each case contains one integer n. The next line contains n (1≤n≤10) numbers: a1,a2,…,an, (1≤ai≤100000).

Output
For each test case, output one line containing “Case #x: y” (without quotes) , where x is the test case number (starting from 1) and y is the answer of Chiaki Nanami’s question.

Sample Input
1
2
3 2

Sample Output
Case #1: 2

题目链接:HDU-5835

题目大意:有n种礼物,给出每种礼物的个数,相邻同学的礼物不能相同,问有多少人个同学能拿到符合要求的礼物。

以下是代码:

#include <bits/stdc++.h>
using namespace std;
int main(){
    int cas = 1;
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int sum = 0,num;
        for (int i = 0; i < n; i++)
        {
            cin >> num;
            sum += num;
        }
        printf("Case #%d: %d\n",cas++,sum/2);
    }
}
版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

HDU 5835 Danganronpa

...神特么弹丸论破 有n种礼物,每种礼物a[I]个,现在有一排无限长的桌子,要往上面放礼物,每个桌子放两个礼物,第一个礼物要求相邻的桌子第一个礼物是不同的,第二个礼物没有这个要求,可以随便选一种礼...

HDU 5835 Danganronpa

将n种礼物分配到一排桌子上,每个桌子上两种礼物,一个普通礼物,一个神秘礼物,相邻桌子上的普通礼物不能相同。问最多可以分配给多少个学生

精选:深入理解 Docker 内部原理及网络配置

网络绝对是任何系统的核心,对于容器而言也是如此。Docker 作为目前最火的轻量级容器技术,有很多令人称道的功能,如 Docker 的镜像管理。然而,Docker的网络一直以来都比较薄弱,所以我们有必要深入了解Docker的网络知识,以满足更高的网络需求。

hdu 5835 Danganronpa

Danganronpa Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To...

HDU 5835 Danganronpa (贪心)

Danganronpa Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To...

HDU-5835 Danganronpa(模拟水题)

Danganronpa Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tota...

hdu 5835 虹软杯 1004 Danganronpa (贪心)

贪心,和强手组队就是要沦为读题专人。

hdu 5835 Danganronpa(贪心,优先队列)

Danganronpa Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) To...

2016CCPC网络赛个人总结

今天下午是2016年的CCPC中国大学生程序设计竞赛的网络赛。几百个学校共计一千多个队参赛。在HDOJ举行。12点开始以后,我们马上看了第一题,嘻嘻哈哈两个星球有着不同的公转周期。给出一个时间。当过了...

树形dp____Magic boy Bi Luo with his excited tree( hdu 5834 2016ccpc网络赛)

Problem Description Bi Luo is a magic boy, he also has a migic tree, the tree has N nodes , in ...

HDU-5833-Zhu and 772002【2016CCPC网络赛】【高斯消元】

1002-Zhu and 772002 题目大意:给出n个数字,问有多少种方式取(1~n)个数字使得成为一个完美平方数 题目思路: 求完全平方数,质因子的范围也知道,所以我们可以对每个质因子列出一个模...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)