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

【洛谷】P9752 [CSP-S 2023] 密码锁

【洛谷】P9752 [CSP-S 2023] 密码锁

题目传送门

题解

CCF数据稳定发挥

暴力出奇迹,这题可以说是这么多年 CSP-s 最水的 A 题了。

n ≤ 8 n \le 8 n8,这个数据很水,所以直接暴力枚举所有的锁的密码的情况,然后暴力比较是否能用 n n n 个密码转换而来。

代码

#include <bits/stdc++.h>
#define lowbit(x) x & (-x)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO {
	inline int read() {
		register int x = 0, f = 1;
		register char c = getchar();
		while (c < '0' || c > '9') {
			if(c == '-') f = -1;
			c = getchar();
		}
		while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
		return x * f;
	}
	inline void write(int x) {
		if(x < 0) putchar('-'), x = -x;
		if(x > 9) write(x / 10);
		putchar(x % 10 + '0');
		return;
	}
}
using namespace fastIO;
int n, lockk[15][15][15][15][15], a, b, c, d, e, ans = 0;
int main() {
	//freopen(" .in", "r", stdin);
	//freopen(". out", "w", stdout);
	n = read();
	for(int i = 1; i <= n; i ++) {
		a = read(), b = read(), c = read(), d = read(), e = read();
		for(int j = 0; j <= 9; j ++) {
			lockk[j][b][c][d][e] ++;
		}
		for(int j = 0; j <= 9; j ++) {
			lockk[a][j][c][d][e] ++;
		}
		for(int j = 0; j <= 9; j ++) {
			lockk[a][b][j][d][e] ++;
		}
		for(int j = 0; j <= 9; j ++) {
			lockk[a][b][c][j][e] ++;
		}
		for(int j = 0; j <= 9; j ++) {
			lockk[a][b][c][d][j] ++;
		}
		for(int j = 1; j <= 9; j ++) {
			lockk[(a + j) % 10][(b + j) % 10][c][d][e] ++;
		}
		for(int j = 1; j <= 9; j ++) {
			lockk[a][(b + j) % 10][(c + j) % 10][d][e] ++;
		}
		for(int j = 1; j <= 9; j ++) {
			lockk[a][b][(c + j) % 10][(d + j) % 10][e] ++;
		}
		for(int j = 1; j <= 9; j ++) {
			lockk[a][b][c][(d + j) % 10][(e + j) % 10] ++;
		}
	}
	for(int A = 0; A <= 9; A ++) {
		for(int B = 0; B <= 9; B ++) {
			for(int C = 0; C <= 9; C ++) {
				for(int D = 0; D <= 9; D ++) {
					for(int E = 0; E <= 9; E ++) {
						if(lockk[A][B][C][D][E] == n) {
							ans ++;
						}
					}
				}
			}
		}
	}
	write(ans), putchar('\n');
	return 0;
}

http://www.kler.cn/news/305011.html

相关文章:

  • C++:opencv生成结构元素用于膨胀腐蚀等cv::getStructuringElement
  • 中级练习[6]:Hive SQL订单配送与用户社交行为分析
  • Windows 环境下安装、使用、nodeJs 连接 TiDB 数据库
  • 使用 Milvus、vLLM 和 Llama 3.1 搭建 RAG 应用
  • 外观模式详解:如何为复杂系统构建简洁的接口
  • UE4_后期处理六—夜视仪、扫描线
  • 瑞芯微RK3568鸿蒙开发板OpenHarmony系统修改cfg文件权限方法
  • 如何提升RAG检索的准确率及答案的完整性?
  • Qt与Udp
  • git update-ref
  • 网络安全 DVWA通关指南 DVWA SQL Injection (Blind SQL盲注)
  • 【iOS】单例模式
  • 使用 PyTorch 构建 MNIST 手写数字识别模型
  • 基于单片机的水情监测站设计
  • TDengine 与飞腾腾锐 D2000 完成兼容互认证,推动国产软硬件深度融合
  • 【方法】如何禁止PDF转换成其他格式文件?
  • Dfa还原某app白盒aes秘钥
  • 微信小程序读写NFC标签(实现NFC标签快速拉起小程序)实战
  • 项目:构建高可用、负载均衡的高效Web服务器
  • 「Qt Widget中文示例指南」如何实现一个系统托盘图标?(二)
  • AndroidManifest.xml文件的重要信息
  • 【YashanDB知识库】archivelog磁盘满导致数据库abnormal
  • 哈莫尼斯 手工王国 Harmonis the hand made kingdoms,官方中文,解压即玩,
  • Java【泛型】
  • Oracle实现行转换成列
  • 【用Java学习数据结构系列】用堆实现优先级队列
  • R 绘图 - 饼图
  • 2024_中秋国庆双节来临 祝CSDN所有开发者与网站节日快乐
  • python画图|极坐标下的3D surface
  • 全局代理与智能分流:哪个更适合你?