蓝桥杯每日一题2023.9.24

九进制转十进制 - 蓝桥云课 (lanqiao.cn)

题目描述

分析

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
	cout << 2 * 9 * 9 * 9 + 0 * 9 * 9 + 2 * 9 + 2;
	return 0;
}

顺子日期 - 蓝桥云课 (lanqiao.cn)

题目描述

分析

全部枚举

cpp 复制代码
#include<bits/stdc++.h>
using namespace std;
int ans = 0;
int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
bool is_ren(int x)
{
	if((x % 4 == 0 && x % 100 != 0) || x % 400 == 0)return true;
	return false;
}
int main()
{
	if(is_ren(2022))m[2] = 29;
	for(int i = 1; i <= 12; i ++)
	{
		for(int j = 1; j <= m[i]; j ++)
		{
			int cnt = 0;
			string s = "2022";
			if(i < 10)s += "0";
			string k = to_string(i);
			//cout << k << "KKK" << '\n';
			s += k;
			if(j < 10)s += "0";
			string q = to_string(j);
			s += q;
			//cout << s << '\n';
			for(int p = 0; p < s.size() - 1; p ++)
			{
				if(s[p] - '0' + 1 == s[p + 1] - '0' && s[p + 1] - '0' + 1 == s[p + 2] - '0')cnt ++;
			}
			if(cnt)ans ++;
		}
	}
	cout << ans;
	return 0;
}
相关推荐
緈福的街口14 小时前
【leetcode】2236. 判断根节点是否等于子节点之和
算法·leetcode·职场和发展
程序员三藏15 小时前
如何使用Pytest进行测试?
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
Z字小熊饼干爱吃保安19 小时前
面试技术问题总结一
数据库·面试·职场和发展
运维开发王义杰19 小时前
打破技术债困境:从“保持现状”到成为变革的推动者
运维·职场和发展
Coding小公仔20 小时前
LeetCode 8. 字符串转换整数 (atoi)
算法·leetcode·职场和发展
GEEK零零七20 小时前
Leetcode 393. UTF-8 编码验证
算法·leetcode·职场和发展·二进制运算
古希腊被code拿捏的神1 天前
【Flutter】面试记录
flutter·面试·职场和发展
凌肖战1 天前
力扣网编程150题:加油站(贪心解法)
算法·leetcode·职场和发展
Memories off2 天前
字节跳动-筋斗云面试记录
面试·职场和发展