Codeforces ABBYY Cup 3.0 / 316A1 316A2 Special Task(模拟&贪心&组合数学)

大型国有银行应用系统全链路性能劣化智能根因定位与自愈Agent平台详细设计方案.docx 立即下载

A1&A2. Special Task
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Special Agent Smart Beaver works in a secret research department of ABBYY. He's been working there for a long time and is satisfied with his job, as it allows him to eat out in the best restaurants and order the most expensive and exotic wood types there.

The content special agent has got an important task: to get the latest research by British scientists on the English Language. These developments are encoded and stored in a large safe. The Beaver's teeth are strong enough, so the authorities assured that upon arriving at the place the beaver won't have any problems with opening the safe.

And he finishes his aspen sprig and leaves for this important task. Of course, the Beaver arrived at the location without any problems, but alas. He can't open the safe with his strong and big teeth. At this point, the Smart Beaver get a call from the headquarters and learns that opening the safe with the teeth is not necessary, as a reliable source has sent the following information: the safe code consists of digits and has no leading zeroes. There also is a special hint, which can be used to open the safe. The hint is string s with the following structure:

  • if si = "?", then the digit that goes i-th in the safe code can be anything (between 0 to 9, inclusively);
  • if si is a digit (between 0 to 9, inclusively), then it means that there is digit si on position i in code;
  • if the string contains letters from "A" to "J", then all positions with the same letters must contain the same digits and the positions with distinct letters must contain distinct digits.
  • The length of the safe code coincides with the length of the hint.

For example, hint "?JGJ9" has such matching safe code variants: "51919", "55959", "12329", "93539" and so on, and has wrong variants such as: "56669", "00111", "03539" and "13666".

After receiving such information, the authorities change the plan and ask the special agents to work quietly and gently and not to try to open the safe by mechanical means, and try to find the password using the given hint.

At a special agent school the Smart Beaver was the fastest in his platoon finding codes for such safes, but now he is not in that shape: the years take their toll ... Help him to determine the number of possible variants of the code to the safe, matching the given hint. After receiving this information, and knowing his own speed of entering codes, the Smart Beaver will be able to determine whether he will have time for tonight's show "Beavers are on the trail" on his favorite TV channel, or he should work for a sleepless night...

Input

The first line contains string s — the hint to the safe code. String s consists of the following characters: ?, 0-9, A-J. It is guaranteed that the first character of string s doesn't equal to character 0.

The input limits for scoring 30 points are (subproblem A1):

  • 1 ≤ |s| ≤ 5.

The input limits for scoring 100 points are (subproblems A1+A2):

  • 1 ≤ |s| ≤ 105.

Here |s| means the length of string s.

Output

Print the number of codes that match the given hint.

Sample test(s)
input
AJ
output
81
input
1?AA
output
100

简单模拟,注意第一个数不是0.

对于较长的密文的处理,有两个小技巧~(详见下方A2代码)


完整代码:

A1

/*30ms,0KB*/

#include<cstdio>
#include<cstring>

char str[5];
bool vis[75];

int main(void)
{
	scanf("%s", str);
	int count = 1, len = strlen(str), j = 10;
	if (str[0] == '?')
		count *= 9;
	else if (str[0] > 64)
	{
		count *= 9;
		j=9;
		vis[str[0]] = true;
	}
	for (int i = 1; i < len; ++i)
	{
		if (str[i] == '?')
			count *= 10;
		else if (str[i] > 64 && !vis[str[i]])
		{
			vis[str[i]] = true;
			count *= j--;
		}
	}
	printf("%d", count);
	return 0;
}


A2

用了点小技巧~

/*30ms,100KB*/

#include<cstdio>
#include<cstring>

char str[100000];
bool vis[75];

int main()
{
	scanf("%s", str);
	int count = 1, charcount = 0, questioncount = 0, len = strlen(str), i, j = 10;
	if (str[0] == '?')
		count *= 9;///这个问号不统计在questioncount中
	else if (str[0] > 64)
	{
		count *= 9;
		j = 9;
		vis[str[0]] = true;
		charcount++;
	}
	for (i = 1; i < len; ++i)
	{
		if (str[i] == '?')
			questioncount++;///统计?出现的次数,然后直接在count后面补上就行,详见最后面的代码
		else if (str[i] > 64 && !vis[str[i]])
		{
			vis[str[i]] = true;
			count *= j--;
			charcount++;
		}
		if (charcount == 9)
			break;///统计到9个字母就只用统计?了~
	}
	for (; i < len; ++i)
		if (str[i] == '?')
			questioncount++;
	printf("%d", count);
	while (questioncount--)
		putchar('0');
	return 0;
}



【深度学习开发环境配置】基于PyTorch的计算机视觉项目依赖管理:requirements.txt文件解析与版本控制方案 内容概要:该文件为一个Python项目的依赖包配置文件(requirements.txt),列出了项目运行所需的软件包及其最低版本要求。主要包括深度学习框架PyTorch及其视觉扩展 torchvision、科学计算库 numpy 和 scipy、数据处理工具 pandas、机器学习库 scikit-learn、图像处理库 opencv-python 和 Pillow,以及数据可视化工具 matplotlib 和 seaborn 等。该配置确保项目在不同环境中具备一致的运行条件。; 适合人群:从事深度学习、计算机视觉或数据科学相关工作的开发者与研究人员,熟悉Python环境管理的技术人员; 使用场景及目标:①用于搭建项目开发环境,确保依赖一致性;②支持模型训练、图像处理、数据分析等任务的环境准备;③便于项目共享与部署,降低环境配置成本; 阅读建议:在实际使用时,建议通过 pip install -r requirements.txt 安装依赖,并根据具体硬件环境适当调整版本兼容性,尤其注意 PyTorch 与 CUDA 版本的匹配。 立即下载

相关推荐

MMCV安装后报错‘from mmcv import Config’?别慌,这是MMCV 2.0的锅!快速降级回退MMCV 1.x全指南

本文详细解析了MMCV 2.0版本升级导致的‘from mmcv import Config’报错问题,提供了从诊断到降级回退MMCV 1.x的完整解决方案。通过pip和OpenMIM工具链的实操指南,帮助开发者快速解决版本冲突,确保项目稳定运行。

weixin_29102619的博客 264

codeforces ABBYY Cup 3.0 - Finals (online version) B2. Shave Beaver!

题目:http://http://codeforces.com/contest/331/problem/B2 题意: 给定一个数组a1,a2,···,an,有两类操作:1.对于i1i1=x,ai2=x+1,···,aik-1=y-1,aik=y,因为可能[x,y]不满足条件,可以把[x,y]分割成[x,p1], [p1+1,p2], ..., [pm+1,y] (xp1p2...p

u011406727的专栏 612

Kalibr标定避坑指南:如何用AprilGrid板快速完成双目IMU标定

本文详细介绍了使用AprilGrid板进行Kalibr双目IMU联合标定的实战技巧,包括标定工具选型、数据采集优化、标定流程及结果验证。通过AprilGrid板的唯一标识性和抗遮挡优势,结合IMU静止标定和运动激励设计,显著提升标定精度。文章还提供了常见报错处理和高级优化技巧,帮助开发者高效完成传感器标定。

sunny的博客 286

A1. Special Task-30 points

time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Special Agent Smart Beaver works in a secret research department

无知的我 1664

基于Zynq的便携式γ能谱仪设计与实现

数字多道分析器(DMCA)是核辐射能谱测量的核心设备,其本质是将探测器输出的模拟脉冲按幅度数字化分道,构建能量-计数分布曲线,从而支撑放射性核素识别与定量分析。其技术原理依赖高速采样、数字滤波成形、基线恢复与峰值提取等关键信号处理环节,具备高分辨率、优线性度与强抗干扰能力。在环境监测、核安全巡检与野外地质勘探等场景中,对低功耗、小型化、实时性提出严苛要求。本方案采用Xilinx Zynq-7020异构SoC架构,融合FPGA实时数字信号处理与ARM嵌入式控制,实现软硬协同优化,兼顾算法精度与工程落地性,为国

weixin_33173126的博客 201

STM32F407步进电机控制及DM542驱动器使用

基于DM542驱动器的步进电机简单控制

qq_43868701的博客 1万+

[ST表] Codeforces Abbyy Cup 2.0-Final B Sequence

题目大意: 题解: 我们考虑最后一个位置是从哪里接收到的消息。 发出消息给最后 一个位置的地方必然位于[n−an,n−1]。然后考虑这个位置是什么。 设S=min(k-ak),n-an≤k≤n−1,对应的最小的k是k0。显然,除非 第一个位置可以直接发消息到最后一个位置,那么消息从k0传递过 来一定不会比从其他位置传递过来更劣。 因此,我们得到了结论:对每个位置n,除非它是直

雯舞 501

【Arc GIS 零基础教学】土地利用类型图的绘制方法

​Hi,我是胡学长!今天教大家怎么利用Arc GIS 绘制土地利用类型图。土地利用类型图是表达土地资源的利用现状、地域差异和分类的专题地图。它是研究土地利用的重要工具和基础资料,同时也是土地利用调查研究的主要成果之一。在编制土地利用图的基础上,对当前利用的合理程度和存在的问题、进一步利用的潜力、合理利用的方向和途径,进行综合分析和评价。因此,土地利用图是调整土地利用结构,因地制宜进行农业、工矿业和交通布局、城镇建设、区域规划、国土整治、农业区划等的一项重要科学依据。......

一起来交流学习吧 1万+

UVa 11264 Coin Collector (选硬币&贪心好题)

思路: 1. 你肯定注意到了,面值最大的硬币c[n-1]必须要选。(反证:如果花了sum元却没有选中它,可知sum<c[n-1],于是用m+c[n-1]元去兑换可以得到一个更优解。) 2. 贪心的关键:假设S(i)是c[1]…c[i] 中那些被选中的货币的面值的和。那么一定有 S(i) < c[i+1]。 3. 所以可以构造一个这样的序列出来。按照2中所说,如果有 S(i-1) < c[i]且S(i) =S(i-1)+c[i]<c[i+1],那么c[i]将被选中。 完整代码:

AC,∑ndless 4699

AI大模型:(三)3.9 Deep Agents实现Agent

DeepAgents是基于LangChain的智能体框架,专为复杂长期任务设计。其通过分层架构解决传统局限,提供智能规划、虚拟文件系统、权限控制、任务委派、上下文管理、人机协同、模型适配及技能系统八大核心功能。相比基础LangChain,它内置状态持久化、流式处理和子智能体调度,显著提升可靠性与自主性。典型应用涵盖自动化编程、复杂业务流程编排及持续学习型研究助手。该框架支持多智能体协作,具备路由分发与动态技能加载能力,适用于需高自主性与安全控制的AI场景,有效实现从代码分析到人工审批的全流程自动化管理。

haylee的专栏 457

DataCastle-租金预测

ID:编号;时间:房屋信息采集的时间;小区名:房屋所在小区,已脱敏处理;小区房屋出租数量:小区出租房屋数量,已脱敏处理;楼层:0、1、2分别表示楼层低,中,高;总层数:房屋所在建筑的总楼层数,已脱敏处理;房屋面积:房屋面积数值,已脱敏处理;房屋朝向:房屋的朝向;居住状态:房屋的居住状态,表示是否已出租或居住中,已脱敏处理;卧室数量:户型信息,数字表示卧室的个数;卫的数量:户型信息,数字表示卫生间的个数;厅的数量:户型信息,数字表示厅的个数;

CSDN 精品推荐 3470

UVa 256 Quirksome Squares (枚举||二次同余)

直接从0~9999枚举即可,因为等式右边一定是个完全平方数。 PS:此题可抽象成一个数论的问题:(部分解法参考了这篇文章) 求解4个二元二次丢番图方程 (x+y)^2=2mx+y,m=10^k / 2 = 2^(k-1)*5^(2k),k=1,2,3,4 令x+y=t,上式化为 t^2-2mt+(2m-1)y=0(由于0<=t^2<10^2k,所以0<=t<10^k) 进而 (t-m)^2=(1-2m)y+m^2 此方程的等价于求解二次同余式

AC,∑ndless 3443

【漏洞复现】WordPress Plugin NotificationX 存在sql注入CVE-2024-1698

技术文章仅供参考,任何个人和组织使用网络应当遵守宪法法律,遵守公共秩序,尊重社会公德,不得利用网络从事危害国家安全、荣誉和利益,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。WordPress和WordPress plugin都是WordPress基金会的产品。WordPress Plugin NotificationX 存在安全漏洞,该漏洞源于对用户提供的参数转义不充分以及对现有 SQL 查询缺乏充分的准备,很容易通过“type”参数受到 SQL 注入攻击。

失心少年 1397

UVa 10049 Self-describing Sequence (自描述序列&二分递推)

10049 - Self-describing Sequence Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=34&page=show_problem&problem=990 Solomon Golomb's self­des

AC,∑ndless 3143

vb 6.0并口开发操作实例

vb6并口开发,简体中文,试例内有inpout32.dll动态链接库

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

UVa 108 Maximum Sum (贪心&最大子矩阵和)

108 - Maximum Sum Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=44 Background A problem that is simple

AC,∑ndless 2786

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

UVa 10057 A mid-summer night's dream. (二分&可以取哪些作为中位数?)

输出注意: 第一个数是最小的A,第二个数是在数列{Xn}中有多少个数可以是A,第三个数是在有多少个数可以是A。 完整代码:

AC,∑ndless 2498

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Codeforces Round #105 (Div. 2) / 148A Insomnia cure (枚举 || 数论)

A. Insomnia cure http://codeforces.com/problemset/problem/148/A time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

AC,∑ndless 2453

AOJ 0033 Ball (枚举)

题意: 有一个形似央视大楼(233)的筒,从A口可以放球,放进去的球可通过挡板DE使其掉进B裤管或C裤管里,现有带1-10标号的球按给定顺序从A口放入,问是否有一种控制挡板的策略可以使B裤管和C裤管中的球从下往上标号递增。  输入: 第一行输入数据组数N。接下来N行为N组具体数据,每组数据中有10个整数,代表球的放入顺序。  输出: 对于每组数据,若策略存在,输出YES;若不存在,输

AC,∑ndless 2325

UVa 12261 High Score (贪心&“向左走,向右走”)

12261 - High Score Time limit: 3.000 seconds  http://uva.onlinejudge.org/index.php?option=onlinejudge&Itemid=99999999&category=244&page=show_problem&problem=3413 思路:注意名字中有若干个A的情况,这时对每串连续的A进行“向左走,

AC,∑ndless 2310

UVa 10125 Sumsets (折半枚举&二分查找)

10125 - Sumsets Time limit: 3.000 seconds  http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=1066 Given S, a set of integers, find the largest d such that a + b +

AC,∑ndless 2305

UVa 1042 Lots of Sunlight (枚举&最优斜率)

1042 - Lots of Sunlight Time limit: 3.000 seconds  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=3483 思路:对于给定的楼层,枚举左、右的最大斜率。 at

AC,∑ndless 2222

USACO The Clocks 一种O(1)的算法

The Clocks IOI'94 - Day 2 Consider nine clocks arranged in a 3x3 array thusly: |-------| |-------| |-------| | | | | | | | |---O | |---O | | O |

AC,∑ndless 2194

UVa 200 Rare Order (拓扑排序)

200 - Rare Order Time limit: 3.000 seconds  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=136 题意:给一列单词,这些单词是按一种未知的字典顺序排列的,要求输出这些字母

AC,∑ndless 2123

UVa 1193 / POJ 1328 / Beijing 2002 Radar Installation (贪心&区间选点)

1193 - Radar Installation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=onlinejudge&page=show_problem&problem=3634 http://poj.org/problem?id=1328 Assume the coasting

AC,∑ndless 2081

UVa 340 Master-Mind Hints (优化查找&复制数组)

学英语: 1. Match (i,j) is called strong when i =j, and is called weak otherwise. 当i=j时,匹配(i,j)被叫做强匹配,反之叫做弱匹配。 2. Two matches (i,j) and (p,q) are called independent when i = p if and only if j = q. A set of matches is called independent when all of its members

AC,∑ndless 2063

Codeforces Round #194 (Div. 1) / 333A Secrets(贪心)

A. Secrets http://codeforces.com/contest/333/problem/A time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ge

AC,∑ndless 2041
上一篇: Codeforces Round #188 (Div. 2) / 318A Even Odds(简单数学)
下一篇: Codeforces Round #195 (Div. 2) / 336A Vasily the Bear and Triangle(模拟&数学)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值