Code
#include <bits/stdc++.h>
#define ll long long
#define mem(a,v) memset(a,v,sizeof (a))
using namespace std;
const int N=2010,INF=0x3f3f3f3f;
void solve(){
int x;
cin>>x;
cout<<"1"<<' '<<x-1<<endl;
}
int main(){
int t;
cin>>t;
while(t--){
solve();
}
}
Code
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n;
void solve(){
scanf("%d",&n);
vector<int>a(n);
for(int i=0;i<n;i++){
scanf("%d",&a[i]);
}
sort(a.begin(),a.end());
a.erase(unique(a.begin(),a.end()),a.end());
cout<<a.size()<<endl;
}
int main(){
int t;
scanf("%d",&t);
while(t--){
solve();
}
}
Code
#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
using namespace std;
const int N=1e5+10;
vector<int>v[N];
int ans[N];
int main(){
int n;
scanf("%d",&n);
for(int i=1;i<n;i++){
int a,b;
scanf("%d%d",&a,&b);
v[a].pb(i);
v[b].pb(i);
ans[i]=-1;
}
pii maxv{0,0};
for(int i=1;i<=n;i++){
maxv=max(maxv,{v[i].size(),i});
}
int now=0;
for (int i:v[maxv.second])
ans[i]=now++;
for(int i=1;i<n;i++){
if(ans[i]==-1)
ans[i]=now++;
printf("%d\n",ans[i]);
}
}
#include <bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define ll unsigned long long
using namespace std;
int main(){
ll u,v;
scanf("%lld%lld",&u,&v);
if(u>v || (v-u)%2){
puts("-1");
return 0;
}
if(u==v && v==0){
puts("0");
return 0;
}
if(u==v && v!=0){
printf("1\n%lld",u);
return 0;
}
ll d=(v-u)/2;
if(u&d){
printf("3\n%lld %lld %lld",u,d,d);
}
else
printf("2\n%lld %lld",u+d,d);
}