首页 > 其他分享 >23级ACM第二次招新测试题解

23级ACM第二次招新测试题解

时间:2023-11-07 23:11:44浏览次数:30  
标签:typedef 招新 23 int ll namespace cin long ACM

A. lyynuu

思路:

先了解子序列的概念:

在数学中,某个序列的子序列是从最初序列通过去除某些元素但不破坏余下元素的相对位置(在前或在后)而形成的新序列

接下来我们就思考什么样的字符串可以让子序列 lynu 形成的数量最多,显然当相同字符连在一起时可以形成尽可能多的 lynu ,例如: llyynnuu 可以形成 \(16\) 个

l l y y n n u u   字符
1 2 3 4 5 6 7 8   位置
可以选:
1 2 5 7
1 2 5 8
1 2 6 7
···
2 4 6 8
总计 2 x 2 x 2 x 2 = 16 种

如果 \(n\) 不能整除 lynu 的个数时,余下的全都变成 u 放最后就好了,最后只需要把这部分也加上就行了,过程看代码。

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	ll n, l = 4;
	cin >> n;
	ll a = n / l, b = n % l;
	if (n < l) cout << 0 << endl;
	else if (n == l) cout << 1 << endl;
	else {
		ll d = pow(a + 1, b) * pow(a, l - b);
		cout << d;
	}
	return 0;
}

B. 输出ASCII码

思路:无

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int main() {
	//cin.tie(0)->ios::sync_with_stdio(0);
	char a;
	cin >> a;
	printf("%d", a);
	return 0;
}

C. 小雨雨打起电动超勇的

思路:无

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	int t1, t2, t3, t4;
	cin >> t1 >> t2 >> t3 >> t4;
	int q;
	bool f = false;
	cin >> q;
	while (q--) {
		int y;
		cin >> y;
		if ((t1 <= y && y <= t2) || (t3 <= y && y <= t4))
			f = true;
	}
	if (f) cout << "Y";
	else cout << "N";
	return 0;
}

D. 熊熊,觅食!

思路:

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	int n;
	cin >> n;
	n = abs(n);
	int a = n / 3, b = n % 3;
	if (b) cout << a + 1;
	else cout << a;
	return 0;
}

E. 小雨雨查找数字

思路:

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int>a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int s;
	cin >> s;
	cout << count(a.begin(), a.end(), s);
	return 0;
}

F. 连续奇数的和

思路:无

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	int x, y, sum = 0;
	cin >> x >> y;
	for (int i = min(x, y) + 1; i < max(x, y); i++)
		if (i & 1) sum += i;
	cout << sum;
	return 0;
}

G. 斐波那契数列

思路:

递推

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int a[N];
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	int n;
	cin >> n;
	a[1] = 1;
	a[2] = 1;
	for (int i = 3; i <= n; i++)
		a[i] = a[i - 1] + a[i - 2];
	cout << a[n];
	return 0;
}

H. 玩游戏

思路:

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int a[N];
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	char a, b;
	cin >> a >> b;
	if (a == 'S' && b == 'J' || a == 'J' && b == 'B' || a == 'B' && b == 'S') printf("Alice");
	else if (a == b)printf("try again~");
	else printf("Bob");
	return 0;
}

I. 排个序

思路:

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int a[N];
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++)
		cout << a[i] << " \n"[i == n - 1];
	return 0;
}

J. 签个到

思路:

代码:

C++:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 100;
int a[N];
int main() {
	cin.tie(0)->ios::sync_with_stdio(0);
	cout << "不去上课就不会迟到啦~" << endl;
	return 0;
}

标签:typedef,招新,23,int,ll,namespace,cin,long,ACM
From: https://www.cnblogs.com/wsccz/p/23ACM_test_002.html

相关文章

  • NOIP2023模拟13联测34 总结
    NOIP2023模拟13联测34总结目录NOIP2023模拟13联测34总结比赛过程题目A.origen题目大意思路B.competition题目大意思路C.tour题目大意D.abstract题目大意比赛过程看了一下题,感觉就\(T2\)有一点思路。\(T1\)先打一个\(30\)分暴力,感觉要分位考虑,想了大概\(1h\)就跳......
  • 华东师大2023程序设计基础代码
    Lab07递归与函数1.正整数的各位数字之和#include<stdio.h>#include<math.h>intsum(inta);intmain(){inta=0;scanf("%d",&a);printf("%d",sum(a));return0;}intsum(inta){if(a<10){ret......
  • 2023.11.7值得推荐的一款服务器空间
    ,已经体验一个月咯,非常不错的免费资源,适合大家去了解了解~!他们家的免费空间,免费服务器,非常稳定,非常靠谱,值得拥有,价格厚道~!免备案服务,域名管理等等服务,应有尽有,2023年你值得了解,他们家的免费云服务器还是独立IP的哦,非常非常好,非常NICE~!官网地址:https://www.sanfengyun.com......
  • 2023.11.7——每日总结
    学习所花时间(包括上课):9h代码量(行):0行博客量(篇):1篇今天,上午学习,下午学习;我了解到的知识点:1.mybatis明日计划:学习......
  • NOIP2023模拟13联测34 B.competition
    NOIP2023模拟13联测34B.competition目录NOIP2023模拟13联测34B.competition题目大意思路code题目大意现在有\(n\)个区间\([l_i,r_i]\),现在问你选取若干的连续的区间的区间并的大小的和。思路设\(pre_{i,j}\)表示前\(i-1\)个区间内,包含点\(j\)的最靠右的......
  • NOIP2023模拟13联测34 A. origen
    NOIP2023模拟13联测34A.origen目录NOIP2023模拟13联测34A.origen题目大意思路code题目大意给定\(n\)个整数\(a_1,a_2,a_3\cdotsa_n\),求\[\sum_{i=1}^n\sum_{j=i}^n(\oplus_{k=i}^ja_k)^2\mod998244353\]\(n\le2*10^5,0\lea_i\le2*10^5\)思路设......
  • NOIP2023模拟8联测29 总结
    NOIP2023模拟8联测29总结题目T1集合大意给出一个序列\(S\),找出有多少个区间\([L,R]\),使得\([L,R]\)值域的连续长度不超过\(k\)。\(n\leq2*10^5,k\leqn\)赛时思路对于区间\([L,R]\),如果有\([L',R']\)符合答案(\(R'\leqR\)且\(L\leqL'\)),那么区间\([L,R']\)......
  • NOIP2023模拟9联测30 总结
    NOIP2023模拟9联测30总结题目T1上海大意判断是否存在\(n\)正整数,使得\(n^2\)是\(k\)的倍数,且\(n\)不是\(k\)的倍数。如果存在,输出最小的\(n\);不存在输出\(-1\)。\(k\leq10^{12}\)赛时思路对于\(n\)来说,\(n\)一定要包含\(k\)有的质因数,而且\(n\)不......
  • NOIP2023模拟9联测32 总结
    NOIP2023模拟9联测32总结题目T1花菖蒲大意构造一个一度点数等于\(a\),二度点数等于\(b\),总点数小于\(2000\)的树。\(a,b\leq200\)赛时思路构造一条链,去除首位后有\(b\)个节点,这\(b\)个节点接一个一度点,加上首位两个一度点,如果一度点不够,那么将首部改造一个一度......
  • 2023 10月随笔、总结
    202310月随笔、总结10月份的事情不多,主要在整问卷答题平台PerfeyePerfeye把之前的自定义画廊给优化了一波,一些bug也给修复了,对比页面算是重构完成了,那就要跟着迭代上线了,上线后,是出现了一些bug,但是都解决了。总体上来说还是很顺利的。问卷答题部门这边要整一个竞赛的活动,......