跳到正文

个人记录

第一次课总结

YR171819约 4 分钟
原文
文章信息与版本

文章信息

发布
2025年9月23日
收录
2025年12月12日
更新
2026年11月17日
篇幅
约 4 分钟

版本

  1. v1当前

题目总结

T1 恐怖银行

题意

让我模拟一次一次取钱

思路

定义x和c然后直接输出x除以1000+c的商乘1000

代码

C++
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,c;
	cin>>x>>c;
	cout<<x/(1000+c)*1000;
	return 0;
}

T2 上锁的房间

题意

让我找到第一个被关闭的门和最后一个被关闭的门

思路

找到第一个被关闭的门和最后一个被关闭的门后直接遍历有几个不能去的然后输出

代码

C++
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
	int n,x=0,y=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]==1)
		{
			x=i;
		}
	}
	for(int i=n;i>=1;i--)
	{
		if(a[i]==1)
		{
			y=i;
		}
	}
	cout<<x-y;
	return 0;
}

T3 密码验证

题意

让我输出合适的密码

思路

最生硬的方法,直接if(注意特判!!!)

代码

C++
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char x;
	string a="";
	int c1=0;
	int c2=0;
	int c3=0;
	int c4=0;
	int c5=0;
	int c6=0;
	while(cin>>x)
	{
		if(x!=',')
		{
			if(x>='a'&&x<='z') c1=1;
			else if(x>='A'&&x<='Z') c2=1;
			else if(x>='0'&&x<='9') c3=1;
			else if(x=='!'||x=='@'||x=='#'||x=='$') c4=1;
			else c5=1;
			c6++;
			a+=x;
		}
		else
		{
			if(c1+c2+c3>=2&&c5!=1&&c6>=6&&c6<=12&&c4>=1)
			{
				cout<<a<<endl;
			}
			c1=c2=c3=c4=c5=c6=0;
			a="";
		}
	}
	if(c1+c2+c3>=2&&c5!=1&&c6>=6&&c6<=12&&c4>=1)
	{
		cout<<a<<endl;
	}
	return 0;
}

题目总结

T4 21点

题意

让我说可不可以抽

思路

得到i<=m的张数和i>m的张数然后比较,最后输出

代码

C++
#include<bits/stdc++.h>
using namespace std;
int t[]={0,0,4,4,4,4,4,4,4,4,16,4};
int main()
{
    int n;
    cin>>n;
    int m=21;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        t[x]--;
        m-=x;
    }
    int cnt1=0,cnt2=0;
    for(int i=1;i<=11;i++)
    {

        if(i<=m)
        {
            cnt1+=t[i];
        }
        else
        {
            cnt2+=t[i];
        }
    }
    if(cnt2>cnt1)
    {
        cout<<"DOSTA";
    }
    else
    {
        cout<<"VUCI";
    }
    return 0;
}
原文