当前位置: 首页 > news >正文

“钉耙编程”2025春季联赛(2)题解(更新中)

1001

学位运算导致的

1002

学历史导致的

// Problem: 学历史导致的
// Contest: HDOJ
// URL: https://acm.hdu.edu.cn/contest/problem?cid=1151&pid=1002
// Memory Limit: 524288 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
// #define int long long
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using PII = pair<int, int>;

const int N = 1e5 + 5;

string a[10] = {"jia", "yi",   "bing", "ding", "wu",
                "ji",  "geng", "xin",  "ren",  "gui"};
string b[12] = {"zi", "chou", "yin",  "mao", "chen", "si",
                "wu", "wei",  "shen", "you", "xu",   "hai"};
vector<string> s(200);
void solve() {
  string c;
  cin >> c;
  for (int i = 0; i < 120; i++) {
    if (s[i] == c) {
      cout << i + 1984 << endl;
      return;
    }
  }
}

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int t;
  cin >> t;
  int cnt = 0;
  for (int i = 0, j = 0; cnt < 200; j++, i++) {
    s[cnt++] = a[i % 10] + b[j % 12];
  }

  while (t--) {
    solve();
  }

  return 0;
}

/*
 *                        _oo0oo_
 *                       o8888888o
 *                       88" . "88
 *                       (| -_- |)
 *                       0\  =  /0
 *                     ___/`---'\___
 *                   .' \\|     |// '.
 *                  / \\|||  :  |||// \
 *                 / _||||| -:- |||||- \
 *                |   | \\\  - /// |   |
 *                | \_|  ''\---/''  |_/ |
 *                \  .-\__  '-'  ___/-. /
 *              ___'. .'  /--.--\  `. .'___
 *           ."" '<  `.___\_<|>_/___.' >' "".
 *          | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *          \  \ `_.   \_ __\ /__ _/   .-` /  /
 *      =====`-.____`.___ \_____/___.-`___.-'=====
 *                        `=---='
 *
 *
 *      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *            佛祖保佑       永不宕机     永无BUG
 */

1003

学数数导致的

 签到题吗?我是菜鸡

我的想法是,找每个数第一次出现的位置和每个位置后面不同数的个数,考虑0的位置

跑一遍数组,记录 i 之前最近的0的位置

a[i]第一次出现在0之前,现在出现在0之后,就在ans上加上i位置后面不同数的个数

感觉题目说的有点别扭

p,q是一对数,p用过之后就不用了,否则会重复,所以记录ans之后把a[i]第一次出现的位置设成非法的

就是p前面有0有p,就加上q,答案记得开i64

// Problem: 学数数导致的
// Contest: HDOJ
// URL: https://acm.hdu.edu.cn/contest/problem?cid=1151&pid=1003
// Memory Limit: 524288 MB
// Time Limit: 6000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
// #define int long long
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using PII = pair<int, int>;

const int N = 1e6 + 5;
int fira[N], q[N];

void solve() {
  fill(fira, fira + N, 0);
  fill(q, q + N, 0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {  // 从1开始,默认是0不要和默认一样
    cin >> a[i];
  }
  for (int i = n; i > 0; i--) {  // 倒着跑真好啊
    if (a[i] == 0) {
      q[i] = q[i + 1];
      continue;
    }
    q[i] = q[i + 1] + (fira[a[i]] == 0);  // 没出现过,新种类++
    fira[a[i]] = i;                       // 倒着跑就是最前的位置
  }
  i64 zero = 0, ans = 0;
  for (int i = 1; i <= n; i++) {
    if (a[i] == 0)
      zero = i;
    else {
      if (fira[a[i]] < zero) {
        ans += q[i + 1];
        fira[a[i]] = 0x3f3f3f3f;
      }
    }
  }
  cout << ans << endl;
}

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int t;
  cin >> t;

  while (t--) {
    solve();
  }

  return 0;
}

/*
 *                        _oo0oo_
 *                       o8888888o
 *                       88" . "88
 *                       (| -_- |)
 *                       0\  =  /0
 *                     ___/`---'\___
 *                   .' \\|     |// '.
 *                  / \\|||  :  |||// \
 *                 / _||||| -:- |||||- \
 *                |   | \\\  - /// |   |
 *                | \_|  ''\---/''  |_/ |
 *                \  .-\__  '-'  ___/-. /
 *              ___'. .'  /--.--\  `. .'___
 *           ."" '<  `.___\_<|>_/___.' >' "".
 *          | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *          \  \ `_.   \_ __\ /__ _/   .-` /  /
 *      =====`-.____`.___ \_____/___.-`___.-'=====
 *                        `=---='
 *
 *
 *      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *            佛祖保佑       永不宕机     永无BUG
 */

1004

学 DP 导致的

 最长上升子序列

但是k太大了,所以超过26次就覆盖所有字母了

比如 z...a

这样排26次就能a..z了

 

 写的时候有点愚蠢啊,s重复26次不要在自身上加,那样是2的26次了

// Problem: 学 DP 导致的
// Contest: HDOJ
// URL: https://acm.hdu.edu.cn/contest/problem?cid=1151&pid=1004
// Memory Limit: 65536 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
// #define int long long
using u32 = unsigned;
using i64 = long long;
using u64 = unsigned long long;
using PII = pair<int, int>;

const int N = 1e5 + 5;

void solve() {
  string s, ss = "";
  cin >> s;
  string k;
  cin >> k;
  int a;
  if (k.size() < 3) {
    a = stoi(k);
    if (a < 26) {
    } else
      a = 26;
  } else
    a = 26;

  for (int i = 0; i < a; i++) {
    ss += s;
  }

  int n = ss.size();
  vector<int> dp(n, 1);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (ss[i] > ss[j]) {
        dp[i] = max(dp[i], dp[j] + 1);
      }
    }
  }

  cout << *max_element(dp.begin(), dp.end()) << endl;
}

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int t;
  cin >> t;

  while (t--) {
    solve();
  }

  return 0;
}

/*
 *                        _oo0oo_
 *                       o8888888o
 *                       88" . "88
 *                       (| -_- |)
 *                       0\  =  /0
 *                     ___/`---'\___
 *                   .' \\|     |// '.
 *                  / \\|||  :  |||// \
 *                 / _||||| -:- |||||- \
 *                |   | \\\  - /// |   |
 *                | \_|  ''\---/''  |_/ |
 *                \  .-\__  '-'  ___/-. /
 *              ___'. .'  /--.--\  `. .'___
 *           ."" '<  `.___\_<|>_/___.' >' "".
 *          | | :  `- \`.;`\ _ /`;.`/ - ` : | |
 *          \  \ `_.   \_ __\ /__ _/   .-` /  /
 *      =====`-.____`.___ \_____/___.-`___.-'=====
 *                        `=---='
 *
 *
 *      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *            佛祖保佑       永不宕机     永无BUG
 */

1005

学几何导致的

180/k*x=90

x=k/2

k为奇数转多少次都不垂直

 有x组相互垂直的

n%x组有n/k+1条

x-(n%x)组有n/k条

1006

学博弈论导致的

1007

学计算导致的

1008

学画画导致的

1009

学高考第19题导致的

1010

学排列导致的

相关文章:

  • 在 Cloud Run 上使用 Gemini API 构建聊天应用
  • linux 服务器创建服务器启动后服务自启动
  • 突破反爬困境:SDK开发,浏览器模块(七)
  • 汇编学习之《标志寄存器》
  • 音视频基础(图像的基础概念)
  • 5.2.1 WPF 通过ItemControl自己做柱状图
  • 英飞凌 TC3xx功能安全开发-MONBIST
  • Redis:List 类型 内部实现、命令及应用场景
  • 探秘Transformer系列之(21)--- MoE
  • 微前端实现方案对比Qiankun VS npm组件
  • EviMed:左手综述内容,右手参考文献!三步产出可溯源的万字医学综述!
  • python系统之综合案例:用python打造智能诗词生成助手
  • 【Python使用】嘿马python数据分析教程第1篇:Excel的使用,一. Excel的基本使用,二. 会员分析【附代码文档】
  • hadoop集群配置-scp命令
  • CTF类题目复现总结-[MRCTF2020]Hello_ misc 1
  • 分治算法之凸包问题
  • 解决ant-ui 表单校验通过但是未清楚校验提示的bug 示例
  • LeetCode算法题(Go语言实现)_21
  • 《C++知识点之拷贝构造函数》
  • Linux系统安装MySQL 8.0完整指南(新手友好版)
  • 怎么在av网站做引流/管理人员课程培训
  • 住房和城乡建设部网站标准下载/什么是搜索引擎优化seo
  • 邢台专业做网站推广/上海优化关键词的公司
  • 武隆专业网站建设公司/网站分析
  • 郑州酒店网站建设/凡科网
  • 云服务器做网站详细/重庆seo整站优化系统