目录(这个链接有点牛马,不建议点,给我整无语了)
Question: Solve: AC Code:
AC Code(元素标记暴力):AC Code(行列标记计算) :
Question: Solve: AC Code:
Notice:天梯赛格式控制是首要的

单纯输出,不加掩饰,没有比python更适合写这道题的语言~
- print("I'm gonna win! Today!")
- print("2022-04-23")

直接向下取整就行,所以也用python写了
- a,b = map(int, input().split(' '))
- print(a // b) #向下取整
Solve: 没什么好办法,按照逻辑顺序设条件就行
- #include <iostream>
- using namespace std;
- int a, b, q1, q2;
- int main(void)
- {
- cin >>a >>b >>q1 >>q2;
- //均大于
- if(q1 >= a && q2 >= a){
- printf("%d-Y %d-Y\n", q1, q2);
- printf("huan ying ru guan");
- //均小于
- }else if(q1 < a && q2 < a){
- printf("%d-N %d-N\n", q1, q2);
- printf("zhang da zai lai ba");
- //可陪同1
- }else if(q1 >= b && q2 < a){
- printf("%d-Y %d-Y\n", q1, q2);
- printf("qing 1 zhao gu hao 2");
- //可陪同2
- }else if(q1 < a && q2 >= b){
- printf("%d-Y %d-Y\n", q1, q2);
- printf("qing 2 zhao gu hao 1");
- //1可入(条件覆盖省略)
- }else if(q2 < a){
- printf("%d-Y %d-N\n", q1, q2);
- printf("1: huan ying ru guan");
- //2可入
- }else{
- printf("%d-N %d-Y\n", q1, q2);
- printf("2: huan ying ru guan");
- }
- return 0;
- }

求阶乘太基础了吧
- #include <iostream>
- using namespace std;
- int res = 1, a, b;
- int main(void)
- {
- cin >>a >>b;
- a += b;
- for(int i = 2; i <= a; i++){
- res *= i;
- }
- cout <<res;
- return 0;
- }

这个题每个骰子都是从6点到1点,只不过要避开初始点数
所以:
投掷次数 <= 6 - 初始点数(正常降序,结果为 6 - n + 1)
投掷次数 > 6 - 初始点数(需要避开,结果为 6 - n)
- #include <iostream>
- using namespace std;
- int a[7], n;
- int main(void)
- {
- for(int i = 1; i <= 6; i++) cin >>a[i];
- cin >>n;
- for(int i = 1; i <= 6; i++){
- if(6 - n >= a[i])
- cout <<7 - n;
- else
- cout <<6 - n;
- if(i != 6) cout <<" ";
- }
- return 0;
- }

直接模拟函数即可
- #include <iostream>
- #include <cstring>
- using namespace std;
- string s1, s2;
- string solve(string s){
- string e = "";
- for (int i = 1; i < s.length(); i++) {
- if (s[i] % 2 == s[i-1] % 2) {
- e += max(s[i], s[i-1]);
- }
- }
- return e;
- }
- int main(void)
- {
- cin >>s1 >>s2;
- string a = solve(s1);
- string b = solve(s2);
- if(a == b) cout <<a;
- else
- cout <<a <<endl <<b;
- return 0;
- }

这个题可以暴力,也可以用数学推导
不过暴力是建立在vector上的,比赛时候直接就过了,如果用数组就TLE了
- #include <bits/stdc++.h>
- using namespace std;
- vector<int>v[100010];
- int main(void)
- {
- int n, m, q;
- scanf("%d%d%d", &n, &m, &q);
- //初始化,向量全部置0
- for(int i = 1; i <= n; i++)
- for(int j = 0; j <= m; j++)
- v[i].push_back(0);
- //修改
- while(q--){
- int t, c;
- scanf("%d%d", &t, &c);
- if(t){
- for(int i = 1; i <= n; i++)
- v[i][c] = 1;
- }else{
- for(int i = 1; i <= m; i++)
- v[c][i] = 1;
- }
- }
- //计数输出
- int res = 0;
- for(int i = 1; i <= n; i++)
- for(int j = 1; j <= m; j++)
- if(!v[i][j]) res++;
- cout <<res;
- return 0;
- }
- #include <iostream>
- #include <cstring>
- #define N 100000
- using namespace std;
- typedef long long ll;
- int row = 0, col = 0; //标记有多少行和列被选中
- bool ro[N+1], co[N+1]; //标记被选中的行和列
- int n, m, q;
- int main(void)
- {
- cin >>n >>m >>q;
- ll res = n * m;
- //初始化
- for(int i = 1; i <= max(n, m); i++)
- ro[i] = co[i] = false;
- //修改
- for(int i = 1; i <= q; i++){
- int t, c; cin >>t >>c;
- if(t){ //选择列
- if(co[c]) continue; //已经选择,直接跳过
- col++; co[c] = true;
- res -= (n - row);
- }else{ //选择行
- if(ro[c]) continue;
- row++; ro[c] = true;
- res -= (m - col);
- }
- }
- cout <<res;
- return 0;
- }

这个题在毫不知情的情况下很容易往 dp 上想,n 阶最长上升子序列?好像也行
但其实只需要把握两个点:
1. PAT成绩达到且天梯赛在 175 分以上的一定可以被推荐,因为这样的选手可以被插在任意一组推荐之中
2. PAT成绩不够但天梯赛在 175 分以上的 同分数最多能选 k 个 ,因为每次推荐都能带走一个
- #include <iostream>
- #include <cstring>
- using namespace std;
- int n, k, s, cnt[291];
- int t, p, res = 0;
- int main(void)
- {
- memset(cnt, 0, sizeof(cnt));
- cin >>n >>k >>s;
- for(int i = 1; i <= n; i++){
- cin >>t >>p;
- //小于175直接跳过
- if(t < 175) continue;
- //PAT分数达到,一定可进
- if(p >= s){ res++; continue; }
- //PAT分数不够,同分数不能超过k
- if(cnt[t] < k){ cnt[t]++, res++; }
- }
- cout <<res;
- return 0;
- }