倒计时37天

23春季选拔开学测补题:

1.题目大致就是给t个n,求n!然后对123456789取模,主要是n的范围比较大,到1e11,当时用数组求得来着,数组开到1e5,之后就不行了,12/25还是12/20,,反正肯定后面段错误,其实有一个点:

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 6;
const int inf = 0x3f3f3f3f;
const int mod = 123456789;

int counting(int x) {
	int result = 1;
	for (int i = 1; i <= x; i++) {
		result = result * i % mod;
	}
	return result;
}

void solve() {
	for (int i = 0; i <= 4000; i++) {
		//cout << counting(i) << endl;
		if (counting(i) == 0) {
			cout << i;
			break;
		}
	}
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int t = 1;
	//cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

所以到3803之后就都是0了,,,

2.L1-094 剪切粘贴 - 团体程序设计天梯赛-练习集 (pintia.cn)

cpp 复制代码
//主要还是理解题意,,,
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 6;
const int inf = 0x3f3f3f3f;
const int mod = 123456789;
void solve()
{
	int n;
    string s;
    cin>>s>>n;
    while(n--)
    {
        int st,en;
        string s1,s2;
        cin>>st>>en>>s1>>s2;
        string str=s.substr(st-1,en-st+1);//是剪切,,T T
        s.erase(st-1,en-st+1);
        string ss=s1+s2;
        int pos=s.find(ss);
        if(pos!=-1)s.insert(pos+s1.size(),str);
        else s+=str;
    }
    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;
}

L2-048 寻宝图 - 团体程序设计天梯赛-练习集 (pintia.cn)

主要就是n,m都到1e5了来着,头来想用二维数组,然后【二维数组最大到1e4】,然后就想用string来着,但不知道哪里错了,,陷入沉思,当时怎么写的来着(・∀・(・∀・(・∀・*)...

想起来了,,,按题意主要是求连通的岛屿个数,但当时的理解就是一个岛屿四周都必须是水才是岛屿,,题目挺简单,主要是理解题意T T,笨蛋,,,题目都看不懂啊啊啊啊啊、、

cpp 复制代码
//用string直接写也可以,这个是dfs的,,老子就不信了,,,每天默念三遍,,不要浮躁,不要浮躁,不要浮躁,,
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 6;
const int inf = 0x3f3f3f3f;
const int mod = 123456789;
vector<int>ve1[N],ve2[N];
int n,m,sum1=0,sum2=0;
int flag=0;
int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
void dfs(int x,int y)
{
    ve2[x][y]=1;
    if(ve1[x][y]>1)flag=1;
    for(int i=0;i<4;i++)
    {
        int xx=x+dir[i][0],yy=y+dir[i][1];
        if(xx>=1&&xx<=n&&yy>=1&&yy<=m&&ve1[xx][yy]&&!ve2[xx][yy])
        {
            if(ve2[xx][yy]>1)flag=1;
            dfs(xx,yy);
        }
    }
}
void solve()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        ve1[i].push_back(0);
        ve2[i].push_back(0);
        for(int j=1;j<=m;j++)
        {
            char a;//不能是int型,要一个一个输入
            cin>>a;
            ve1[i].push_back(a-'0');
            ve2[i].push_back(0);
        }
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            if(ve1[i][j]&&!ve2[i][j])
            {
                flag=0;
                sum1++;
                dfs(i,j);
                if(flag)sum2++;
            }
        }
    }
    cout<<sum1<<' '<<sum2;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
	int t = 1;
	//cin>>t;
	while (t--) {
		solve();
	}
	return 0;
}

待续,,题目名忘了T T...

相关推荐
sinat_2765225744 分钟前
C++中move的使用
开发语言·c++
微尘81 小时前
C语言存储类型 auto,register,static,extern
服务器·c语言·开发语言·c++·后端
金博客1 小时前
Qt 模型视图(二):模型类QAbstractItemModel
c++·qt6.7.2
五味香2 小时前
C++学习,动态内存
java·c语言·开发语言·jvm·c++·学习·算法
无名之逆2 小时前
计算机专业的就业方向
java·开发语言·c++·人工智能·git·考研·面试
Beauty.5682 小时前
P1328 [NOIP2014 提高组] 生活大爆炸版石头剪刀布
数据结构·c++·算法
jimmy.hua2 小时前
C++刷怪笼(5)内存管理
开发语言·数据结构·c++
xiaobai12 32 小时前
二叉树的遍历【C++】
开发语言·c++·算法
DieSnowK2 小时前
[项目][WebServer][Makefile & Shell]详细讲解
开发语言·c++·http·makefile·shell·项目·webserver
dc爱傲雪和技术3 小时前
在 VS Code 中调试 C++ 项目
开发语言·c++