Codeforces Round #628 (Div. 2)【A B C D】

传送门

A. EhAb AnD gCd

直接输出1,n-1即可

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=1e5+50;
const int inf=0x3f3f3f3f;
const int M=5000*4;
int a[MAXN];

int main()
{
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    ll n;
    while(t--){
    	cin>>n;
    	cout<<1<<" "<<n-1<<endl;
    }
    return 0;
}
/*

*/

B. CopyCopyCopyCopyCopy

找数组中一共有多少个不同的元素
(可以直接放到set里,输出set的长度即可,set可以去重)

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <vector>
#include <math.h>
#include <map>
#include <queue>
#include <set>
#include <stack>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
typedef long long ll;
using namespace std;
const int MAXN=1e5+50;
const int inf=0x3f3f3f3f;
const int M=5000*4;
int a[MAXN];

int main()
{
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int t;
    cin>>t;
    int n;
    while(t--){
    	map<ll,ll>p;
    	cin>>n;
    	int ans=0;
    	rep(i,1,n){
    		cin>>a[i];
    		if(p[a[i]]==0){
    			p[a[i]]=1;
    			ans++;
    		}
    	}
    	cout<<ans<<endl;
    }
    return 0;
}
/*

*/

C.Ehab and Path-etic MEXs

Codeforces Round #628 (Div.2) C.Ehab and Path-etic MEXs(树,思维)

D. Ehab the Xorcist

Codeforces Round #628 (Div. 2) D. Ehab the Xorcist(异或构造,思维)

发布了169 篇原创文章 · 获赞 15 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/weixin_44091178/article/details/104876477