离散题目2
来源:互联网 发布:插画师dorami辞软件 编辑:程序博客网 时间:2024/06/05 18:11
离散题目2
Time Limit: 1000MS Memory Limit: 65536KB
Submit Statistic
Problem Description
DaYu是一个喜欢看电影的好孩子,他的电脑里有成千上万部电影。因为某些不可描述的原因,他把这些电影以互不相同的编号命名(编号是数字且范围在(0,1000000)之间)。因为电影实在太多,他记不住自己已经看过了哪些电影。现在他把他看电影的记录给你,请你帮他检查一下他有没有看重复的电影。如果没有,输出“true”,否则输出“false”。
Input
第一行输入组数T(T<1000),每组的第一行输入他看的电影数量n(0 < n < 1000000),第二行输入n个数字,分别是每一部电影的编号。
Output
对于每组数据,如果没有重复的,那么输出true,否则输出false。
Example Input
251 2 3 4 551 2 3 4 4
Example Output
truefalse
代码:#include <bits/stdc++.h>using namespace std;int main(){int t;cin>>t;while(t--){int n;int a[1000005];cin>>n;for(int i = 0; i < n; i++){cin>>a[i];}sort(a, a+n);int flag = 1;for(int i = 0; i < n-1; i++){if(a[i] == a[i+1]){flag = 0;break;}}if(flag)cout<<"true"<<endl;else cout<<"false"<<endl;}return 0;}
阅读全文
0 0
- 离散题目2
- 离散题目2
- 离散题目2
- 离散题目2
- 离散题目2
- 离散题目2
- sdut-l离散题目2
- 离散题目2(查找重复元素)
- 离散题目3
- 离散题目7
- sdut离散题目11
- sdut离散题目13
- sdut离散题目14
- 离散题目12
- 离散题目15
- 3799-->离散题目5
- 3800-->离散题目6
- 离散题目1
- Mysql脚本升级之根据查询条件进行insert动作
- 51Nod-1049 最大子段和【DP】
- Android 自定义ViewGroup
- WIN下安装TensorFlow
- 清理weblogic缓存
- 离散题目2
- 文件路径读取
- dbForge Studio for MySQL v7.2发布,视图和界面全面更新|附下载
- Spring Boot 使用 Druid 和监控配置
- vpn
- LruCache
- Mac下userdefault的路径
- linux防火墙iptables详细教程
- iOS