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

Sample Output
Case #:

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5835

****************************************************

题意:有T组测试实例,每组实例有n种类型的礼物,第i种类型的礼物共有a[i]个,相邻同学的礼物不能相同,问有多少个同学能拿到符合要求的礼物。

分析:从这道题里我学到了勇于尝试的重要性%>_<%~ 脑洞尽管开,试一试不会亏呀

这道题里并没有要求童鞋们要挨着坐,所以嘞,随便坐喽,这说明了神马,这就说明了这是一道水题%>_<%~

只需要判断一人俩礼物能分几个人的问题。。。。

那些还在研究怎么坐得到的结果最多又怎么实现的童鞋们~~~你们都被出题的人给坑坏了

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <vector>
using namespace std; #define N 12000
#define INF 0x3f3f3f3f int a[N]; int main()
{
int T,n,i,sum,k=; scanf("%d", &T); while(T--)
{
sum=;
scanf("%d", &n); for(i=;i<n;i++)
{
scanf("%d", &a[i]);
sum+=a[i];
} printf("Case #%d: ",k++);
if(sum==)
printf("1\n");
else
printf("%d\n", sum/);
}
return ;
}

附上一个让不明白的人更明白的代码:

 #include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <math.h> using namespace std; #define met(a, b) memset(a, b, sizeof(a))
#define N 53
#define INF 0x3f3f3f3f
#define PI 4*atan(1)
const int MOD = ; typedef long long LL; int a[N]; int main()
{
int T, t = , n, sum;
scanf("%d", &T);
while(T--)
{
sum = ;
scanf("%d", &n); for(int i=; i<=n; i++)
{
scanf("%d", &a[i]);
sum += a[i];
} sort(a+, a+n+); int half = sum/; int s = sum-a[n]; if(*s+ < half)
printf("Case #%d: %d\n", t++, *s+);
else
printf("Case #%d: %d\n", t++, half);
}
return ;
}

2016中国大学生程序设计竞赛 - 网络选拔赛 1004 Danganronpa的更多相关文章

  1. 2016中国大学生程序设计竞赛 - 网络选拔赛 C. Magic boy Bi Luo with his excited tree

    Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migi ...

  2. 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob

    Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) ...

  3. 2016中国大学生程序设计竞赛 网络选拔赛 I This world need more Zhu

    This world need more Zhu Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  4. 2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String

    Problem Description Lweb has a string S. Oneday, he decided to transform this string to a new sequen ...

  5. 2016中国大学生程序设计竞赛 - 网络选拔赛 1001 A water problem (大数取余)

    Problem Descripton Two planets named Haha and Xixi in the universe and they were created with the un ...

  6. 2017中国大学生程序设计竞赛 - 网络选拔赛 1004 HDU 6153 A Secret (字符串处理 KMP)

    题目链接 Problem Description Today is the birthday of SF,so VS gives two strings S1,S2 to SF as a presen ...

  7. 2018中国大学生程序设计竞赛 - 网络选拔赛 1001 - Buy and Resell 【优先队列维护最小堆+贪心】

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6438 Buy and Resell Time Limit: 2000/1000 MS (Java/O ...

  8. 2018中国大学生程序设计竞赛 - 网络选拔赛 1010 YJJ's Salesman 【离散化+树状数组维护区间最大值】

    题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6447 YJJ's Salesman Time Limit: 4000/2000 MS (Java/O ...

  9. 2018中国大学生程序设计竞赛 - 网络选拔赛 1009 - Tree and Permutation 【dfs+树上两点距离和】

    Tree and Permutation Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

随机推荐

  1. erlang四大behaviour之二-gen_fsm

    来源:http://www.cnblogs.com/puputu/articles/1701012.html 今天介绍erlang的一个非常重要的behaviour,就是gen_fsm-有限状态机,有 ...

  2. webstorm2016.2.4激活码

    测试日期:2016.11.07 webstorm版本:2016.2.4 系统环境:MacOS(windows环境应该也行) 激活码如下: 43B4A73YYJ-eyJsaWNlbnNlSWQiOiI0 ...

  3. 运行指定路径下的exe

    public void StartProcess(string name) { string exeFileName = "DataControl.exe"; string sta ...

  4. Redis简介二

    一.直接安装     1.Windows版本的Redis下载地址:https://github.com/dmajkic/redis/downloads  ,选择一个你想要下载的版本下载即可~     ...

  5. 有关android安全性的问题--代码混淆

    转自:http://www.cnblogs.com/dream-sky/archive/2012/11/15/2771648.html 在project.properties里加上   proguar ...

  6. C语言_愤怒的小鸟

    // ConsoleApplication4.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include<stdio.h> ...

  7. vi 操作技巧

    输入模式的操作Home光标到行首End 光标到行尾Page Up和Page Down上下翻页Delect删除光标位置的字符 删除操作(命令模式使用)x删除光标处的单个字符dd删除光标所在行dw删除当前 ...

  8. Java中String转换Double类型 Java小数点后留两位

    Java中String转换Double类型 double num1 = 0.0; String qq = "19.987"; num1 = Double.valueOf(qq.to ...

  9. Infix expressions 中缀表达式

    中缀表达式的计算 利用两个栈来实现,操作数栈,操作符栈 只支持个位数运算 最后必须输入一个'#' #include<iostream> using namespace std; templ ...

  10. LeetCode OJ 108. Convert Sorted Array to Binary Search Tree

    Given an array where elements are sorted in ascending order, convert it to a height balanced BST. 把一 ...