1140 Look-and-say Sequence

#include <iostream>

using namespace std;

int main() {

string s;

int n, j;

cin >> s >> n;

for (int cnt = 1; cnt < n; cnt++) {

string t;

for (int i = 0; i < s.length(); i = j) {

for (j = i; j < s.length() && s[j] == s[i]; j++);

t += s[i] + to_string(j - i);

}

s = t;

}

cout << s;

return 0;

}

相关推荐
rainbow68891 小时前
C++开源库dxflib解析DXF文件实战
开发语言·c++·开源
John_ToDebug1 小时前
Chromium安全架构深度解析:从悬空指针检测到内存安全防御体系
c++·chrome
静听山水1 小时前
Redis核心数据结构-ZSet
数据结构·redis
D_evil__1 小时前
【Effective Modern C++】第五章 右值引用、移动语义和完美转发:24. 区分万能引用和右值引用
c++
铉铉这波能秀1 小时前
LeetCode Hot100数据结构背景知识之字典(Dictionary)Python2026新版
数据结构·python·算法·leetcode·字典·dictionary
蜡笔小马1 小时前
10.Boost.Geometry R-tree 空间索引详解
开发语言·c++·算法·r-tree
唐梓航-求职中1 小时前
编程-技术-算法-leetcode-288. 单词的唯一缩写
算法·leetcode·c#
仟濹2 小时前
【算法打卡day3 | 2026-02-08 周日 | 算法: BFS】3_卡码网99_计数孤岛_BFS | 4_卡码网100_最大岛屿的面积DFS
算法·深度优先·宽度优先
Ll13045252982 小时前
Leetcode二叉树part4
算法·leetcode·职场和发展
林开落L2 小时前
从零开始学习Protobuf(C++实战版)
开发语言·c++·学习·protobuffer·结构化数据序列化机制