寒假学习内容总复习上:
1.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int a[110];
void solve()
{
for(int i=0;i<100;i++)
{
cin>>a[i];
}
int ans=0;
for(int i=1;i<=12;i++)
{
for(int j=1;j<=month[i];j++)
{
string s="2023";
if(i<10)s+='0';
s+=to_string(i);
if(j<10)s+='0';
s+=to_string(j);
int t=0;
for(int k=0;k<100;k++)
{
if(a[k]==s[t]-'0')t++;
if(t==8){ans++;break;}
}
}
}
cout<<ans;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
2.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
void solve()
{
int cn=0;
for(int i=1;i<=12;i++)
{
for(int j=1;j<=month[i];j++)
{
string s="2022";
if(i<10)s+='0';
s+=to_string(i);
if(j<10)s+='0';
s+=to_string(j);
for(int k=1;k<=6;k++)
{
if(s[k]-s[k-1]==1&&s[k+1]-s[k]==1)
{
cn++;
break;
}
}
}
}
cout<<cn;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
3.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 6;
const int inf = 0x3f3f3f3f;
int a[110], b[110];
map<int, int>mp;
void solve() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
b[i] = a[i];
mp[a[i]] = i;
}
sort(a + 1, a + 1 + n);
int cn = 0;
for (int i = 1; i <= n; i++) {
if (a[i] != b[i]) {
mp[b[i]] = mp[a[i]];
b[mp[a[i]]] = b[i];
b[i] = a[i];
cn++;
}
}
cout << cn;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
//cin>>t;
while (t--) {
solve();
}
return 0;
}
4.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 6;
const int inf = 0x3f3f3f3f;
int gcd(int a, int b) {
if (a < b)
swap(a, b);
int c = 1;
while (c) {
c = a % b;
a = b;
b = c;
}
return a;
}
void solve() {
int a, b;
cin >> a >> b;
cout << gcd(a, b);
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
5.
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
int m,k;
struct cmp
{
bool operator()(const int &a,const int &b)
{
if(abs(a-b)<=k)return false;
return a<b;
}
};
set<int,cmp>se;
void solve()
{
cin>>m>>k;
for(int i=1;i<=m;i++)
{
string s;
int x;
cin>>s>>x;
if(s=="add")
{
se.insert(x);
}
else if(s=="del")
{
se.erase(x);
}
else
{
if(se.find(x)!=se.end())
{
cout<<"Yes"<<endl;
}
else cout<<"No"<<endl;
}
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
6.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 6;
const int inf = 0x3f3f3f3f;
void solve() {
int n, m;
cin >> n >> m;
char a[110];
_itoa(n, a, m);
cout << a;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
7.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 6;
const int inf = 0x3f3f3f3f;
char a[110], b[110];
void solve() {
cin >> a;
int len = strlen(a), sum = 0;
for (int i = 0; i < len; i++) {
b[i] = a[i] - '0';
if (b[i] == 1)
sum += pow(2, len - i - 1);
}
cout << sum;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
8.
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 6;
const int inf = 0x3f3f3f3f;
void solve() {
int a, b, c = -inf, n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
if (i == 0)
b = a;
else
b = max(a, a + b);
c = max(b, c);
}
cout << c;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
int t = 1;
//cin >> t;
while (t--) {
solve();
}
return 0;
}
9.
补题:(0条未读通知) 牛客小白月赛87_ACM/NOI/CSP/CCPC/ICPC算法编程高难度练习赛_牛客竞赛OJ (nowcoder.com)
//c
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
void solve()
{
int n,k;
cin>>n>>k;
string s;
cin>>s;
while(k--)
{
string ss;
cin>>ss;
int flag=s.find('I');
if(flag==-1)break;
if(ss=="backspace")
{
if(flag&&s[flag-1]=='('&&s[flag+1]==')')
{
s.erase(flag+1,1);
s.erase(flag-1,1);
}
else if(flag)
{
s.erase(flag-1,1);
}
}
else if(flag!=s.size()-1)s.erase(flag+1,1);
}
cout<<s;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
//d
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
void solve()
{
int n,k;
cin>>n>>k;
string s;
cin>>s;
while(k--)
{
string ss;
cin>>ss;
int flag=s.find('I');
if(flag==-1)break;
if(ss=="backspace")
{
if(flag&&s[flag-1]=='('&&s[flag+1]==')')
{
s.erase(flag+1,1);
s.erase(flag-1,1);
}
else if(flag)
{
s.erase(flag-1,1);
}
}
else if(ss=="delete"&&flag!=s.size()-1)s.erase(flag+1,1);
else if(ss=="<-")
{
if(flag)
{
s[flag]=s[flag-1];
s[flag-1]='I';
}
}
else
{
if(flag!=s.size()-1)
{
s[flag]=s[flag+1];
s[flag+1]='I';
}
}
}
cout<<s;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
//e
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
int a[N];
void solve()
{
int n;
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
int r=0;
cout<<0;
for(int i=1;i<n;i++)
{
r=a[i-1]-a[i];
if(r<=0)r=0;
else a[i]=a[i-1];
cout<<' '<<r;
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}
//f
/*
知识点:
a[i]&a[j]<=a[i],a[i]&&a[j]<=a[j];
a[i]|a[j]>=a[i],a[i]|a[j]>=a[j];
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e5+6;
const int inf=0x3f3f3f3f;
int a[N],b[N],ans;
void solve()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=n-1;i>=1;i--)
{
b[i]=(b[i+1]|a[i]);
}
int r=0;
for(int i=1;i<=n-2;i++)
{
r^=a[i];
ans=max(ans,a[n]+b[i+1]+r);
}
cout<<ans;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr),cout.tie(nullptr);
int t=1;
//cin>>t;
while(t--)
{
solve();
}
return 0;
}