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 ...
随机推荐
- java基础(1)
class test { static { a=3; //System.out.println(a); } static int a = 1; String b = "ff"; p ...
- javascript焦点图之缓冲滚动无缝切换
在用于实现无缝切换四张图,所以设置了6个图片就是 4,0,1,2,3,4,0 <!DOCTYPE html> <html> <head> <meta char ...
- AJAx 刷新页面
<html><head> <meta http-equiv="Content-Type" content="text/html; chars ...
- 笔记一:OOAD与UML
一.面向对象的概念与方法 1. 面向对象 1.1. 面向对象是一种系统建模技术 1.2. 面向对象编程是按照OO的方法学来开发程序的过程 1.3. 通过分析系统内对象的交互来描述或建模一个系统 1. ...
- 01背包dp+并查集 Codeforces Round #383 (Div. 2)
http://codeforces.com/contest/742/problem/D 题目大意:有n个人,每个人有重量wi和魅力值bi.然后又有m对朋友关系,朋友关系是传递的,如果a和b是朋友,b和 ...
- tableview选择的时候不要cell的高亮显示样式
1.若用方法: //-(BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)ind ...
- JPA 系列教程15-继承-一个表-SINGLE_TABLE
继承映射策略 一个类继承结构一个表的策略,最终只生成一个表,这是继承映射的默认策略. 举例 如果实体类Teacher继承实体类Person,实体类Student也继承自实体Person,那么只会映射成 ...
- jquery各版本区别
jquery版本区别: 1.3一般功能够 1.4.2一般功能够而且稳定 1.7+比较新特性 2不支持老IE 兼容的话最好选 1.x.稳定性就用1.7或者1.4,其中1.4的体积相对 ...
- php错误记录
1.模板不存在ThinkPHP\Library\Think\View.class.php LINE: 110 是因为IndexController的Index函数,而View中没有对应的Index文件 ...
- VC MFC工具栏(CToolBar)控件
一.工具栏 工具栏控件在控件面板里没有对应的选项(图标),但有一个工具栏控件类CToolBar,所以我们如果要创建一个工具栏控件并显示在窗口里的话,只能用代码来完成,事实上任何一种控件,都可以用代码创 ...