2016中国大学生程序设计竞赛 - 网络选拔赛 1004 Danganronpa
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?
Each case contains one integer n. The next line contains n (1≤n≤10) numbers: a1,a2,...,an, (1≤ai≤100000).
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的更多相关文章
- 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 ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 J. Alice and Bob
Alice and Bob Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- 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 ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1011 Lweb and String
Problem Description Lweb has a string S. Oneday, he decided to transform this string to a new sequen ...
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1001 A water problem (大数取余)
Problem Descripton Two planets named Haha and Xixi in the universe and they were created with the un ...
- 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 ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1001 - Buy and Resell 【优先队列维护最小堆+贪心】
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6438 Buy and Resell Time Limit: 2000/1000 MS (Java/O ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1010 YJJ's Salesman 【离散化+树状数组维护区间最大值】
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6447 YJJ's Salesman Time Limit: 4000/2000 MS (Java/O ...
- 2018中国大学生程序设计竞赛 - 网络选拔赛 1009 - Tree and Permutation 【dfs+树上两点距离和】
Tree and Permutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Oth ...
随机推荐
- Openjudge-计算概论(A)-过滤多余的空格
描述: 一个句子中也许有多个连续空格,过滤掉多余的空格,只留下一个空格. 输入一行,一个字符串(长度不超过200),句子的头和尾都没有空格.输出过滤之后的句子. 样例输入 Hello world.Th ...
- ECOS-Ecstore 伪静态规则
.htaccess 文件 RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME ...
- AJAx 刷新页面
<html><head> <meta http-equiv="Content-Type" content="text/html; chars ...
- docker network
前言:前面的部分一直都是单机跑docker,但实际生产环境不可能只用一台来跑.肯定会用到多台,因为他们都是内部私有ip,那么多台主机之间的容器如何通信?这个是个很头疼的问题!目前主流几种方法如下: 1 ...
- html5--基础笔记
1.对于<a>标签 以前: <h2><a href="index.html">The home page</a></h2> ...
- mysql之TIMESTAMP(时间戳)用法详解 [http://www.jb51.net/article/51794.htm]
一.TIMESTAMP的变体 TIMESTAMP时间戳在创建的时候可以有多重不同的特性,如: 1.在创建新记录和修改现有记录的时候都对这个数据列刷新: TIMESTAMP DEFAULT CURREN ...
- 模仿QQ客户端和服务器(支持window和linux)
界面部分我还没有想好,到底是用MFC还是duilib呢? 好吧我先发一个demo版本,功能都有,以下为功能展示. 先说服务器(这个有俩个版本,支持win和linux):用的数据库为MYsql(因为是便 ...
- 【第五篇】androidEventbus源代码阅读和分析之unregister代码分析
代码里面注销eventbus一般我们会在onDestory里面这么写: EventBus.getDefault().unregister(this); 然后走到unregister里面去看看: /** ...
- eclipse 中执行 main 函数如何添加参数
我们通常执行 main 函数都是直接在类界面 右键 选择 Run As --> Java Application 但是如何 执行时带有参数呢? 右键 --> Run As --> R ...
- crontab定时任务以及其中中文乱码问题
一.小例子 1.写个测试文件 2.将文件权限变为可执行文件 3.在crontab文件中写定时任务 格式: 分/时 * * * 用户名 可执行文件路径 >> log文件路径 2>&am ...