网站建设 交单流程,狗和女人做的网站,网站 维护 页面,上传网站到百度A
SSeeeeiinngg DDoouubbllee
题意#xff1a;告诉你一个字符串。若该串上每一位上的字母都可以出现两次#xff0c;求回文串
思路#xff1a;正向再反向输出s即可
#include bits/stdc.h
#define lowbit(x) x(-x)
#define ios cin.sync_with_stdio(false)…A
SSeeeeiinngg DDoouubbllee
题意告诉你一个字符串。若该串上每一位上的字母都可以出现两次求回文串
思路正向再反向输出s即可
#include bits/stdc.h
#define lowbit(x) x(-x)
#define ios cin.sync_with_stdio(false)
#define PII pairint,int
typedef long long ll;
const int N1e610;
const int inf0x3f3f3f3f;using namespace std;
int n;
string s;
void solve()
{cins;couts;reverse(s.begin(),s.end());couts\n;
}
int main()
{//ios;int _t1;cin_t;while(_t--) solve();system(pause);return 0;
}
B
XOR Average
题意让你构造长度为n的数组满足
思路n为奇数时全为1 n为偶数时两个元素为1和3其余为2
#include bits/stdc.h
#define lowbit(x) x(-x)
#define ios cin.sync_with_stdio(false)
#define PII pairint,int
typedef long long ll;
const int N1e610;
const int inf0x3f3f3f3f;using namespace std;
int n;
int a[N];
void solve()
{cinn;if(n1){for(int i1;in;i) a[i]1;}else {for(int i3;in;i) a[i]2;a[1]1,a[2]3;}for(int i1;in;i)couta[i] \n[in];
}
int main()
{//ios;int _t1;cin_t;while(_t--) solve();system(pause);return 0;
}
C
Almost All Multiples
题意给定n和x构造长度为n且字典序最小的排列。满足Pn1,P1x, i | Pi (1 i n-1)
思路先不考虑字典序最小当n%x0时有解让pxn其他位置不变即可。n%x!0时假设我们在x的位置填k*x那么k*x的位置要填p*k*x若最后一个x倍数的位置不能填n就是无解的即n%x!0.
考虑字典序最小x的位置我们先填2*x要保证n是所填数的倍数且所填数未出现过(否则到这个位置上的时候也无法用n替代那么也是不行的。)不行就填3*x4*x...
#include bits/stdc.h
#define lowbit(x) x(-x)
#define ios cin.sync_with_stdio(false)
#define PII pairint,int
typedef long long ll;
const int N1e610;
const int inf0x3f3f3f3f;using namespace std;
int n,x;
int a[N];
bool vis[N];
void solve()
{cinnx;for(int i1;in;i) vis[i]0;if(n%x!0){cout-1\n;return ;}a[1]x;a[n]1;vis[x]1;vis[1]1;for(int i2;in;i){if(vis[i]){int cnt2;while(n%(cnt*i)!0!vis[cnt*i]cnt*in) cnt;a[i]cnt*i;vis[cnt*i]1;}else{a[i]i;vis[i]1;}}for(int i1;in;i)couta[i] \n[in];
}
int main()
{//ios;int _t1;cin_t;while(_t--) solve();system(pause);return 0;
}
D
Range √Sum
题意 给定长度n让你构造长度为n且各元素不同满足以下条件的数组 思路n为偶数时我们让元素为n1,n-1,n2,n-2,....nn/2,n-n/2.极差为n且总和为n*n n为奇数时我们先让n1变成偶数用上述方法构造。然后删去元素n-1,再让其余n-1个元素都加一这样极差和总和是未发生改变的。
#include bits/stdc.h
#define lowbit(x) x(-x)
#define ios cin.sync_with_stdio(false)
#define PII pairint,int
typedef long long ll;
const int N1e610;
const int inf0x3f3f3f3f;using namespace std;
int n;
void solve()
{cinn;vectorinta;if(n%20){for(int i1;in/2;i) coutni ;for(int i1;in/2;i) coutn-i ;cout\n;}else{for(int i1;i(n1)/2;i) a.push_back(n1i);for(int i2;i(n1)/2;i) a.push_back(n1-i);for(int i0;ia.size();i) couta[i]1 \n[in-1];}
}
int main()
{//ios;int _t1;cin_t;while(_t--) solve();system(pause);return 0;
}