倒计时67天

复习。

一.倒计时79天-CSDN博客

1.

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
void solve()
{
  int a[110]={},cn=0;
  for(int i=0;i<100;i++)cin>>a[i];
	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 k=0;
      for(int i=0;i<100;i++)
      {
        if(a[i]==s[k]-'0')++k;
        if(k==8){cn++;break;}
      }
    }
  }
  cout<

2.

#include
using namespace std;
#define int long long
const int N=3e4+5;
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);//20220101
  		for(int k=1;k<7;k++)
  		{
  			if(s[k]-s[k-1]==1&&s[k+1]-s[k]==1)
  			{
  				cn++;
  				break;
			}
		}
	}
  }
  cout<

3.

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;
int a[N], b[N];
mapmp;

void solve() {
	int n, cn = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
		mp[a[i]] = i;
	}
	sort(a, a + n);
	for (int i = 0; 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);
	solve();
	return 0;
}

4.

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;

int gcd(int a, int b) {
	if (a < b)
		swap(a, b);
	int c;
	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);
	solve();
	return 0;
}

5.

#include
using namespace std;
#define int long long
const int N=1e5+5;
const int inf=0x3f3f3f3f;
int a[N],b[N];
bool cmp(int x,int y)
{
    return b[x]>n;
    for(int i=0;i>a[i];
        b[a[i]]=i;
    }
    int m;
    cin>>m;
    int l=0,r=n;
    for(int i=0;i>s>>c;
        if(s=="FIRST")b[c]=--l;
        else b[c]=++r;
    }
    sort(a,a+n,cmp);
    for(int i=0;i

6.

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
int k;
struct cmp{
    bool operator()(const int &a,const int &b)
    {
        if(abs(a-b)<=k)return false;//别忘了绝对值,n次了,又忘了╥﹏╥...
        return ase;
void solve()
{
	int m;
    cin>>m>>k;
    for(int i=0;i>s>>x;
        if(s=="add")
        {
            se.insert(x);
        }
        else if(s=="del")
        {
            se.erase(x);
        }
        else
        {
            if(se.find(x)!=se.end())
            {
                cout<<"Yes"<

7.

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;
stackst;

void solve() {
	int m, n;
	cin >> m >> n; //m->n进制
	while (m) {
		int c = m % n;
		st.push(c);
		m /= n;
	}
	while (st.size()) {
		cout << st.top();
		st.pop();
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	solve();
	return 0;
}

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;
stackst;

void solve() {
	int m, n;
	cin >> m >> n; //m->n进制
	char str[220];
	_itoa(m, str, n);
	cout << str;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	solve();
	return 0;
}

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;
void solve() {
	string a;
	cin >> a; //二进制到十进制
	int sum=0;
	int le=a.size();
	for(int i=0;i

8.

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;
void solve() {
	int n,a,b,mx=-inf;
	cin>>n;
	for(int i=0;i>a;
		if(i==0)b=a;
		else b=max(a+b,b);
		mx=max(mx,b);
	}
	cout<

9.

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;

void solve() {
	int t;
	cin >> t;
	while (t--) {
		vectorve;
		int n;
		cin >> n;
		for (int i = 1; i <= n; i++) {
			ve.push_back(i);
		}
		int flag = 0;
		while (ve.size() > 3) {
			if (flag == 0) {
				flag = 1;
				for (int i = 1; i < ve.size(); i++) {//是小于ve.size(),不是n或小于等于,不然会溢出
					ve.erase(ve.begin() + i, ve.begin() + i + 1);
				}
			} else {
				flag = 0;
				for (int i = 2; i < ve.size(); i += 2) {
					ve.erase(ve.begin() + i, ve.begin() + i + 1);
				}
			}
		}
		for (auto i : ve)
			cout << i << ' ';
		cout << endl;
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	solve();
	return 0;
}

10.

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;

void solve() {
	int n;
	while(cin>>n&&n)
	{
		string s1,s2;
		setse1,se2;
		for(int i=0;i>s1>>s2;
			se1.insert(s1),se1.insert(s2);//所有人
			se2.insert(s2);//失败者
		}
		if(se1.size()-se2.size()==1)cout<<"Yes"<

11.

#include
using namespace std;
#define int long long
const int N=2e5+5;
const int inf=0x3f3f3f3f;
int aa[N];
void solve()
{
	int n,m,a,b=0,cn=0;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        if(a!=b)
        {
            ++cn;
            b=a;
        }
        aa[i]=cn;
    }
    for(int i=1;i<=m;i++)
    {
        int l,r;
        cin>>l>>r;
        cout<

12.

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
priority_queue,greater >qu;
void solve()
{
	int q,y=0;
    cin>>q;
    while(q--)
    {
        int m,x;
        cin>>m;
        if(m==1)
        {
            cin>>x;
            qu.push(x-y);
        }
        else if(m==2)
        {
            cout<>x;
            y+=x;
        }
    }
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	solve();
	return 0;
}

13.

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;
setse;
void solve()
{
	string s,word;
	while(cin>>s)
	{
		for(int i=0;i>word)
		{
			se.insert(word);
		}
	}
	for(auto i:se)cout<

14.

#include 
using namespace std;
#define int long long
const int N = 3e4 + 5;
const int inf = 0x3f3f3f3f;

void solve() {
	//vector
	vectorve = {1, 3, 3, 6, 15};
	int tag = 3;
	cout << lower_bound(ve.begin(), ve.end(), tag) - ve.begin() << endl;
	//map
	mapmp = {{1, 2}, {1, 1}, {3, 1}, {2, 4}, {4, 5}};
	auto it = mp.lower_bound(2);
	cout << it->first << ' ' << it->second << endl;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	solve();
	return 0;
}

例:C-又放学辣(简单)_牛客小白月赛80 (nowcoder.com)

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
int k;
mapmp;
bool check(int mid,int i)
{
    int cn=0;
    for(auto x:mp)
    {
        cn+=max(0ll,x.second-mid);
    }
    if(mp[i]>=mid)cn-=(mp[i]-mid);
    if(cn>k)return false;
    else return true;
}
void solve()
{
	int n,m,a;
    cin>>n>>m>>k;
    for(int i=0;i>a;
        mp[a]++;
    }
    for(int i=1;i<=m;i++)
    {
        if(n-k>1;
            if(check(mid,i))r=mid;
            else l=mid+1;
        }
        cout<

二.倒计时78天-CSDN博客

1.

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
int a[110][110],b[110][110];
struct node{
	int x,y,step;
};
queuequ;
void solve()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
		}
	}
	int sx,sy,ex,ey,st=0;
	cin>>sx>>sy>>ex>>ey;
	qu.push({sx,sy,st});
	b[sx][sy]=1;
	while(!qu.empty())
	{
		int mx=qu.front().x,my=qu.front().y;
		if(mx==ex&&my==ey)
		{
			cout<=1&&rx<=n&&ry>=1&&ry<=m&&a[rx][ry]==1&&b[rx][ry]==0)
			{
				node ww;
				b[rx][ry]=1;
				ww.x=rx,ww.y=ry,ww.step=qu.front().step+1;
				qu.push(ww);
			}
		}
		qu.pop();
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr),cout.tie(nullptr);
	solve();
	return 0;
}
/*
输入:
5 4
1 1 2 1
1 1 1 1
1 1 2 1
1 2 1 1
1 1 1 2
1 1 4 3
输出:
7
*/

2.

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
string s[510];
int r[510][510];
int dir[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
typedef pair pii;
int n,m;
void bfs(int i,int j)
{
    queuequ;
    memset(r,0,sizeof r);
    bool flag=0;
    qu.push({i,j});
    while(!qu.empty())
    {
        int rx=qu.front().first,ry=qu.front().second;
        r[rx][ry]=1;
        if(s[rx][ry]=='E')
        {
            cout<<"Yes"<=0&&zx=0&&zy>n>>m)
    {
        for(int i=0;i>s[i];
        for(int i=0;i

3.

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
string s[1100];
int ss[1100][1100];
int dir[4][2]={{0,1},{1,0},{-1,0},{0,-1}};
typedef pair pii;
queuequ;
int ans=0;
int n,m;
void bfs(int i,int j)
{
    int cn=1;
    setse1,se2;
    qu.push({i,j});
    while(!qu.empty())
    {
        int sx=qu.front().first,sy=qu.front().second;
        se1.insert(sx),se2.insert(sy);
        ss[sx][sy]=1;
        for(int i=0;i<4;i++)
        {
            int zx=sx+dir[i][0],zy=sy+dir[i][1];
            if(zx>=0&&zx=0&&zy>n>>m;
    for(int i=0;i>s[i];
    for(int i=0;i

4.

#include
using namespace std;
#define int long long
const int N=3e4+5;
const int inf=0x3f3f3f3f;
string s1[4],s2[4];
typedef pair pii;
int n;
vectorve1,ve2;
int dir[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{-1,-1},{1,-1},{-1,1}};
void bfs1(int i,int j)
{
    queuequ;
    qu.push({i,j});
    int cn1=1;
    while(!qu.empty())
    {
        int sx=qu.front().first,sy=qu.front().second;
        qu.pop();
        for(int i=0;i<8;i++)
        {
            int rx=sx+dir[i][0],ry=sy+dir[i][1];
            if(rx>=0&&rx<4&&ry>=0&&ryqu;
    qu.push({i,j});
    int cn2=1;
    while(!qu.empty())
    {
        int sx=qu.front().first,sy=qu.front().second;
        qu.pop();
        for(int i=0;i<8;i++)
        {
            int zx=sx+dir[i][0],zy=sy+dir[i][1];
            if(zx>=0&&zx<4&&zy>=0&&zy>n;
    for(int i=0;i<4;i++)cin>>s1[i];
    for(int i=0;i<4;i++)cin>>s2[i];
    for(int i=0;i<4;i++)
    {
        for(int j=0;jve2.size())cout<<-1;
    else
    {
        int sum=0;
        for(int i=ve2.size()-1;i>=0&&i>=ve1.size()-1;i--)//i要>=0,注意!!!
        {
            sum+=ve2[i];
        }
        cout<

...........................脑子转不动了(((φ(◎ロ◎;)φ)))...............待续。。。。。。.......................................

你可能感兴趣的:(c++)