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

Modscan32连接上了却没数据?一文拆解所有报错(从“Device NOT CONNECTED”到“Checksum Error”) 本文深入解析Modscan32连接异常问题,从状态栏报错到数据异常,提供系统化的诊断思路和解决方案。涵盖物理层问题、配置参数错位、端口占用冲突等常见故障,帮助工程师快速定位和解决Modbus通信中的各类错误。 阅读详情

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;
}



多重共线性问题 -- 岭回归方法 概述 本篇博客分为三大部分,线性模型、多重共线性问题和岭回归。其中,线性模型中介绍了线性模型定义和普通最小二乘法对线性模型的拟合。第二部分,借由1987-2007年的人口、消费和科技对碳排放的影响的数据来说明多重共线性问题(包括如何从定性和定量两个方面判断多重共线性问题)和多重共线性问题对普通最小二乘估计的影响。第三部分,使用岭回归对第二部分中的多重共线性问题进行拟合,并基于R2R^2R2决定系数... 阅读详情

相关推荐

别再手动搬数据了!用rclone一键同步MinIO到华为云OBS的保姆级教程

本文详细介绍了如何使用rclone工具实现MinIO到华为云OBS的数据迁移,包括环境准备、双端配置、迁移前验证、实战迁移及后期监控等步骤。通过rclone的增量同步、断点续传等功能,确保数据迁移高效安全,特别适合需要跨云存储迁移的用户。

weixin_30839881的博客 523

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

Calibre LVS错误排查实战:从Innovus到GDS的完整调试流程(附常见错误解析)

本文详细介绍了数字IC后端设计中,从Innovus工具输出数据到Calibre LVS物理验证的完整调试流程。文章系统性地讲解了LVS错误排查的方法论,包括报告解读、图形化定位以及针对器件不匹配、电源网络错误、短路开路等常见问题的深度解析与解决方案,旨在帮助工程师高效完成版图与原理图的一致性检查。

weixin_29218963的博客 776

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

关于Oxford Radar RobotCar Dataset的学习笔记

https://oxford-robotics-institute.github.io/radar-robotcar-dataset/documentation 简介 雷达是 Navtech CTS350-X 调频连续波 (FMCW) 扫描雷达,在所使用的配置中提供 4.38 cm 的距离分辨率和 0.9 度的旋转分辨率,范围高达 163 m,同时提供对天气条件的稳健性这可能会给其他传感器模式带来麻烦。在其他配置中,Navtech CTS350-X 可以提供超过 650 m 的范围和更高的旋转速度。然而,对

禾烁的博客 5297

基于GPU的GEMM矩阵相乘运算优化

从上图中我们可以看到三种处理方法。第一种是将A和B矩阵分块,第二种方法是将C和B矩阵分块,第三种方法是将C和A矩阵分块。GEMM的子任务是GEPP或GEMP;最小粒度的任务是GEBP或GEPB或点乘。

weixin_55035144的博客 2156

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

逆向拆解dy接口a_bogus 1.0.1.19版本核心算法(纯算版)第二部分

本文深入解析了dy接口a_bogus 1.0.1.19版本的核心算法,重点介绍了逆向分析的基础方法论、魔改Base64编码识别与还原、随机数生成与位运算解析等关键技术。通过详细的代码示例和实用技巧,帮助开发者掌握逆向工程中的关键步骤,特别是针对a_bogus参数的生成逻辑和混淆处理。

weixin_29288313的博客 408

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

SolidWorks 2022 学习(一)软件安装

接下来是安装SolidWorks,右键SolidWorks.2022.SP0.Premium.DVD.iso,选择装载。然后以管理员身份运行SolidWorks_Flexnet_Server目录下的server_install.bat。更改需要安装的产品,以及安装路径,并勾选接受条款,点击现在安装,会弹出如下窗口。然后以管理员身份运行setup.exe,开始安装solidworks。下载链接会在文章末尾给出,下载完成的文件如下图所示。双击注册表文件,然后点击确定。保持不动,点击确定,开始安装。

qq_38383364的博客 3129

【2022】人工智能☆✨

1. 朴素⻉叶斯⽅法是⼀种 ( ) ⽅法。A.机器学习的分类B.不确定性推理C.知识表示答案:A解析:朴素贝叶斯分类器是基于贝叶斯定理与特征条件独立假设的分类方法。它通过学习训练数据集来预测未知数据的类别标签,因此属于机器学习中的监督学习分类方法。选项B不确定性推理和选项C知识表示虽然与朴素贝叶斯方法有一定的关联,但它们并不是朴素贝叶斯方法的主要应用领域或定义特性。2. 关于启发式搜索描述正确的是 ( )。

super_mochi1 400

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

YOLO系列算法改进 | Neck改进篇 | 融合FAAFusion傅里叶角度对齐模块 | 攻克多尺度方向特征冲突,角度检测精度飙升! | CVPR 2026

YOLO系列算法改进 | Neck改进篇 | 融合FAAFusion傅里叶角度对齐模块 | 攻克多尺度方向特征冲突,角度检测精度飙升! | CVPR 2026 (以YOLO26最新目标检测模型为基础,利用FAAFusion傅里叶角度对齐模块改进Neck部分)

2502_91881744的博客 315

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

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

AC,∑ndless 2495

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

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

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

AOJ 0033 Ball (枚举)

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

AC,∑ndless 2325

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

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的博客 248

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、付费专栏及课程。

余额充值