zoj 3959 Problem Preparation
来源:互联网 发布:双语名著阅读软件 编辑:程序博客网 时间:2024/06/05 21:51
题目链接:Problem Preparation
题目大意:给你一堆数,需要做到的是最小值必须是1,且1的个数不少于两个,最大值只能有一个,相邻两个数之间差的绝对值不能大于2(如果相邻两个数有最大值就不做这个要求),数的个数不能小于10或者大于13。
题目思路:直接按照题目来写和判断就可以了
#include <bits/stdc++.h>using namespace std;int main(){ int t,n,a[1005],flag; scanf("%d",&t); while(t--){ scanf("%d",&n); flag = 0; for(int i = 0;i < n;i++) scanf("%d",&a[i]); sort(a,a+n); if(n < 10||n > 13) flag = 1; else{ if(a[0] != 1||a[1] != 1||a[n-1] == a[n-2]) flag = 1; else{ for(int i = 1;i < n-1;i++) if(abs(a[i]-a[i-1]) > 2) {flag = 1;break;} } } if(flag == 1) puts("No"); else puts("Yes"); } return 0;}
0 0
- ZOJ 3959 Problem Preparation
- ZOJ 3959 Problem Preparation 【】
- zoj 3959 Problem Preparation
- ZOJ 3959Problem Preparation
- Problem Preparation
- Problem Preparation
- Problem Preparation
- Problem Preparation T
- ZOJ3959-Problem Preparation
- Preparation
- Problem Preparation for HTML to TXT
- ZOJ Problem 1374 Substrings
- ZOJ Problem Set - 2060
- ZOJ Problem Set - 2972
- ZOJ Problem Set - 1037
- ZOJ Problem Set - 1048
- ZOJ Problem Set - 1049
- ZOJ Problem Set - 1051
- Linux变量
- 具体的设计模式(二):结构型模式
- hdu 3605 Escape【图论-网络流-最大流-状态压缩】
- 相对定位和绝对定位的练习
- [Binder机制]大管家ServiceManager启动流程
- zoj 3959 Problem Preparation
- 14. Longest Common Prefix
- 关于Android Studio使用.9.png图片引起的的Error:Execution failed for task ':app:mergeDebugResources'. 问题
- 安卓硬件加速
- java将一个List赋值给另一个List相关问题
- 备份数据库
- Android 出现java.lang.NoClassDefFoundError错误的一种解决方案
- IDEA搭建最简单的springMVC
- java造型