UVa 11063 - B2-Sequence
2016-03-28 21:58
423 查看
题目:给你一组数据{ b1,b2。...,bk }中,推断是否随意两个数字的和都不同。
分析:数论。计算出全部结果,排序推断相邻结果是否同样就可以。
说明:注意数据的合法性检查。
分析:数论。计算出全部结果,排序推断相邻结果是否同样就可以。
说明:注意数据的合法性检查。
#include <algorithm> #include <iostream> #include <cstdlib> #include <cstdio> using namespace std; int data[111]; int sum[5555]; int main() { int n,T = 1; while (~scanf("%d",&n)) { for (int i = 0 ; i < n ; ++ i) scanf("%d",&data[i]); int count = 0,flag = 0; for (int i = 0 ; i < n ; ++ i) for (int j = i ; j < n ; ++ j) sum[count ++] = data[i]+data[j]; if (data[0] < 1) flag = 1; for (int i = 1 ; i < n ; ++ i) if (data[i] <= data[i-1]) { flag = 1; break; } sort(sum, sum+count); for (int i = 1 ; i < count ; ++ i) if (sum[i] == sum[i-1]) { flag = 1; break; } if (!flag) printf("Case #%d: It is a B2-Sequence.\n\n",T ++); else printf("Case #%d: It is not a B2-Sequence.\n\n",T ++); } return 0; }
相关文章推荐
- UIView的基本属性及ANimation
- STL中vector、list、deque和map的区别
- uva10128(Queue)
- iOS之UITableView的上拉刷新
- OC中的Values——and——Collections
- 303. Range Sum Query - Immutable
- easyui-combobox实现级联查询
- uestc1134男神的约会【状压dp】
- Fluent NHibernate other example
- iOS - UITableViewCell reload 数据刷新method
- [leetcode] 53. Maximum Subarray
- 《leetCode》:Repeated DNA Sequences
- Atitit.Gui控件and面板----数据库区-mssql 2008 权限 配置 报表查看成员
- UVA 540 —— Team Queue
- java 乱码详解_jsp中pageEncoding、charset=UTF -8"、request.setCharacterEncoding("UTF-8")
- 理解 Android Build 系统
- EasyUI学习笔记
- 梳理caffe代码blocking_queue(十)
- iOS UITableView4
- iOS UITableView3