学习打卡第15天

昨天进行了线上比赛
才做了三道题就不行了
果然是大彩笔
吐槽一下罚时的原因
C那一道是数组上限设定错了
那个18w的测试点真的恶心
G是没打\n 真的服了我自己了
但E理解错题意是最要命的qaq
就是简单的查数
所以今天分享一下那道憨憨E

E. CopyCopyCopyCopyCopy
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Ehab has an array a of length n. He has just enough free time to make a new array consisting of n copies of the old array, written back-to-back. What will be the length of the new array’s longest increasing subsequence?

A sequence a is a subsequence of an array b if a can be obtained from b by deletion of several (possibly, zero or all) elements. The longest increasing subsequence of an array is the longest subsequence such that its elements are ordered in strictly increasing order.

Input
The first line contains an integer t — the number of test cases you need to solve. The description of the test cases follows.

The first line of each test case contains an integer n (1≤n≤105) — the number of elements in the array a.

The second line contains n space-separated integers a1, a2, …, an (1≤ai≤109) — the elements of the array a.

The sum of n across the test cases doesn’t exceed 105.

Output
For each testcase, output the length of the longest increasing subsequence of a if you concatenate it to itself n times.
就是简单的一个不重复排序
下面是代码

#include <cstdio>
#include <algorithm>
using namespace std;
int a[100010];
int main(){
	int t,n,m,i;
	scanf("%d",&t);
	while(t--){
		scanf("%d",&n);
		for(i=1;i<=n;i++)scanf("%d",&a[i]);
		sort(a+1,a+1+n);
		m=unique(a+1,a+1+n)-(a+1);
		printf("%d\n",m);
	}
}

想复杂了
其实很简单

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值