Codeforces Round #177 (Div. 1) / 288A Polo the Penguin and Strings(贪心)

影刀RPA进阶:Excel多条件筛选与数据提取实战 本文详细介绍了如何利用影刀RPA实现Excel多条件筛选与数据提取的自动化。通过拆解文本、数值、日期及颜色筛选等核心指令,并结合实战案例,指导用户构建稳健的销售数据提取机器人,从而高效处理复杂数据报表,提升工作效率。 阅读详情

A. Polo the Penguin and Strings
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Little penguin Polo adores strings. But most of all he adores strings of length n.

One day he wanted to find a string that meets the following conditions:

  1. The string consists of n lowercase English letters (that is, the string's length equals n), exactly k of these letters are distinct.
  2. No two neighbouring letters of a string coincide; that is, if we represent a string as s = s1s2... sn, then the following inequality holds,si ≠ si + 1(1 ≤ i < n).
  3. Among all strings that meet points 1 and 2, the required string is lexicographically smallest.

Help him find such string or state that such string doesn't exist.

String x = x1x2... xp is lexicographically less than string y = y1y2... yq, if either p < q and x1 = y1, x2 = y2, ... , xp = yp, or there is such number r (r < p, r < q), that x1 = y1, x2 = y2, ... , xr = yr and xr + 1 < yr + 1. The characters of the strings are compared by their ASCII codes.

Input

A single line contains two positive integers n and k (1 ≤ n ≤ 106, 1 ≤ k ≤ 26) — the string's length and the number of distinct letters.

Output

In a single line print the required string. If there isn't such string, print "-1" (without the quotes).

Sample test(s)
input
7 4
output
ababacd
input
4 7
output
-1

大水题。


完整代码:

/*30ms,0KB*/

#include<cstdio>

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	if (n < k)
		printf("-1");
	else if (n == k)
		for (int i = 97; i < 97 + k; ++i)
			putchar(i);
	else if (k == 1)
		printf("-1");
	else
	{
		n -= k - 2;
		if (n & 1)
		{
			n = (n - 1) >> 1;
			for (int i = 0; i < n; ++i)
			{
				putchar('a');
				putchar('b');
			}
			putchar('a');
		}
		else
		{
			n >>= 1;
			for (int i = 0; i < n; ++i)
			{
				putchar('a');
				putchar('b');
			}
		}
		for (int i = 99; i < 97 + k; ++i)
			putchar(i);
	}
	return 0;
}



YOLO11涨点优化:loss优化 | 一种新的基于Wasserstein距离的小目标检测评估方法,助力小目标涨点 提出了一种新的基于Wasserstein距离的小目标检测评估方法,通过它们对应的高斯分布计算它们之间的相似性 阅读详情

相关推荐

抖音X-Medusa风控逆向:unidbg环境重建与魔改AES还原

X-Medusa并非传统加密算法,而是深度耦合运行时环境的动态混淆系统,其核心是硬件指纹感知、线程上下文绑定与非标AES变异。理解其原理需跳出‘找密钥’思维,转向对CPU型号、系统属性、微秒级时间及内存布局的综合建模。技术价值在于将不可控的客户端风控,转化为可复现、可配置、可运维的服务化能力;典型应用场景包括合规数据采集、API协议适配与移动安全研究。本文聚焦Android native层逆向实践,基于unidbg实现高保真环境模拟,并完整还原S-Box动态生成、MixColumns矩阵变异与轮密钥XOR扰

weixin_33783283的博客 686

Codeforces Round #177 (Div. 1) A - Polo the Penguin and Strings

贪心,尽量把不同的数向后填。。。 #include #include #include #include #include #include #include #include #include #include #include #include #include #define maxn 1000005 #define maxm 2000005 #define ep

yysys 735

新手避坑指南:在MacBook上为PyTorch正确配置MPS环境,跑通第一个YOLOv8训练

本文详细指导新手如何在MacBook上为PyTorch正确配置MPS环境,并成功运行YOLOv8训练。从环境准备、PyTorch安装到YOLOv8配置和性能调优,提供全面的避坑指南和实用技巧,帮助开发者充分利用Mac的GPU加速能力。

weixin_29100399的博客 228

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

SAP ABAP CDS View 里的日期函数

摘要:本文系统介绍了ABAP CDS日期函数在企业级应用中的关键作用,包括账龄计算、合同续期等业务场景。重点解析了DATS_IS_VALID、DATS_DAYS_BETWEEN等核心函数的语义和使用边界,特别强调on_error四种异常处理策略的选择逻辑。针对系统日期获取,对比了经典CDS的参数注入和View Entity会话变量两种方式。文章还提供了完整可运行的示例代码(包含CDS视图和ABAP程序),帮助开发者快速验证不同版本下的函数行为差异,确保在实际项目中正确应用这些日期处理函数。(149字)

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 379

基于MUSIC算法的DOA估计Matlab仿真

特别需要指出的是:通道与阵元并不是一一对应,通道是由空间的一个、几个或所有阵元合成的,当然空间某个特定的阵元可包含在不同的通道内。空间谱估计侧重于研究空间多传感器阵列所构成的处理系统对感兴趣的空间信号的多种参数进行准确估计的能力,其主要目的是估计信号的空域参数或信源位置,这也是雷达、通信、声纳等许多领域的重要任务之一。从系统框图中可以清晰的看出,估计空间相当于是对目标空间的一个重构过程,这个重构的精度由众多因素决定,如环境的复杂性、空间阵元的互耦、通道不一致、频带不一致等。

FPGA/MATLAB学习教程/源码/项目合作开发 1747

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 3440

【OpenClaw从入门到精通】第13篇:OpenClaw低代码编排实战:非技术人员也能玩转AI自动化流程(2026新版实测)

本文聚焦OpenClaw 2026版核心升级的低代码编排能力,针对非技术人员的实操需求,从底层逻辑、双环境部署、三类实战案例、避坑指南四个维度展开。详解阿里云集群版(企业级)与汉化本地版(个人调试)的部署步骤,通过基础数据统计、公众号内容生产线、企业级任务调度三个递进式案例,演示可视化拖拽搭建自动化流程的完整过程。全程零代码/低代码操作,配套详细参数配置、执行结果模拟及问题排查方案,帮助销售、运营、自媒体等非技术人员快速掌握自动化工具,将重复工作交给AI,提升核心工作效率。

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 617

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

SAP-ABAP:字符与数值类型转换详细指南

SAP-ABAP:字符与数值类型转换详细指南

baidu_35680696的博客 1480

使用R语言获取data.frame中指定列的数据

这里以"df"为例,包含三列数据:“列1”、“列2"和"列3”。通过以上代码,我们成功获取了"列1"和"列3"的数据,并将它们分别存储在了变量"column1"和"column3"中。假设我们有一个名为"df"的data.frame,其中包含了多个列,我们想要提取其中的某一列。符号,我们可以从data.frame中提取出"列2"的数据,并将其赋值给变量"column2"。符号,我们可以轻松提取出data.frame中特定列的数据,并将其存储在变量中供进一步的分析和处理使用。假设我们要获取"列2"的数据。

DevRevolt的博客 2321

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 2784

极智芯 | 解读国产CPU之海光

大家好,我是极智视界,本文分享一下 解读国产CPU之海光。希望我的分享能对你的学习有一点帮助。

极智视界 3319

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

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

AC,∑ndless 2495

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

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

Statistics and Machine Learning Toolbox

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

AOJ 0033 Ball (枚举)

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

AC,∑ndless 2325

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

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 2192

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 2122

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

深挖C++:类和对象(中)

(先进后出)

xys_678的博客 246

C++移动构造函数详解

移动构造函数是C++11引入的一种特殊构造函数,用于从临时对象(右值)"窃取"资源来初始化新对象,而不是进行昂贵的深拷贝。char* data;public:// 移动构造函数:参数是右值引用 &&// 关键:把源对象的资源置空。

拒绝AI文,努力在AI时代写出感动人心的好文章 392
上一篇: Codeforces Round #195 (Div. 2) / 336A Vasily the Bear and Triangle(模拟&数学)
下一篇: Codeforces Round #182 (Div. 2) / 302A Eugeny and Array(模拟)
synapse7
博客等级 码龄14年 432粉丝 701原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值