内容补充
2025-12-07 18:32:28
发布于:广东
//函数sort的功能:排序(升序)
// int a[N];
//排序区间[l,r];
//sort(a+l,a+r+1);//排序区间为[l,r+1)
// vector<int>v;
//sort(v.begin(),v.end());
//printf("%.2f",x);//格式化输出保留四位小数,
//%lf--->double %f---->float;
//A ASCII码 65 a 97
// char c;
// int(c);//类型强转
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
struct Node{
int a,b;//根据a的值进行排序
};
bool cmp(Node x1,Node x2){
return x1.a>x2.a;
}
Node a[N];
sort(a,a+n,cmp);
//map 键值对,字典,key,value
void solve(){
map<int,int>mp;
int n,q;
cin>>n>>q;
for(int i=1;i<=n;i++){
int x;
cin>>x;
if(mp.count(x))continue;
mp[x]=i;
}
while(q--){
int x;
cin>>x;
if(mp.count(x)){
cout<<mp[x]<<' ';
}else{
cout<<-1<<' ';
}
}
}
int main(){
int t=1;
// cin>>t;
while(t--){
solve();
}
}
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
void solve(){
int n;
cin>>n;
int len=1;
char c='A';
for(int i=1;i<=n;i++){
for(int i=1;i<=len;i++){
cout<<c++;
if(c>'Z')c='A';
}
cout<<endl;
len++;
}
}
int main(){
int t=1;
// cin>>t;
while(t--){
solve();
}
}
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
void solve(){
int n,m;
cin>>n>>m;
map<int,int>mp;
for(int i=1;i<=m;i++){
int x;
cin>>x;
if(x>=n)continue;
mp[x]++;
}
if(n==mp.size()){
cout<<n<<endl;
}else{
for(int i=0;i<n;i++){
if(!mp[i])cout<<i<<' ';
}
}
}
int main(){
int t=1;
// cin>>t;
while(t--){
solve();
}
}
这里空空如也







有帮助,赞一个