清华计科考研2022复试机考-模拟

22年模拟机考T1,T2都是签到题。T3和调剂机考撞车,T4数论。

  • T1: 签到
  • T2: 签到
  • T3: 大模拟
  • T4: 数论

传送门

T1 A+B Problem

1
2
3
4
5
6
7
8
#include <cstdio>
int main()
{
long long a,b;
scanf("%lld%lld",&a,&b);
printf("%lld\n",a+b);
return 0;
}

T2 k叉树

先使用 BFS 或并查集判定是否是树。如果是树的话,对每个点的度进行分析:如果度$\le k$,做内部节点做根都满足题意;如果度$=k+1$,做内部节点可以,不能做根;如果度$\lt k+1$,做内部节点做根都不满足题意。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <queue>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int m,k;
bool vis[100010];
vector<int> to[100010];
vector<int> ans;
queue<int> q;
bool istree()
{
vis[0]=true,q.push(0);
while(!q.empty())
{
int pos=q.front();
q.pop();
for(auto i:to[pos]) if(!vis[i]) vis[i]=true,q.push(i);
}
for(int i=0;i<=m;++i) if(!vis[i]) return false;
return true;
}
int main()
{
scanf("%d%d",&m,&k);
int x,y;
for(int i=0;i<m;++i) scanf("%d%d",&x,&y),to[x].push_back(y),to[y].push_back(x);
if(!istree())
{
printf("It's not a tree!\n");
return 0;
}
for(int i=0;i<=m;++i)
if(to[i].size()>k+1)
{
printf("No such a node!\n");
return 0;
}
for(int i=0;i<=m;++i)
if(to[i].size()!=k+1)
{
printf("%d\n",i);
return 0;
}
return 0;
}

T3 租约机制

模拟题跟调剂题撞车。

怎么会是呢.jpg

传送门

T4 初等数论

1
//TODO