1140. Look-and-say Sequence (20)

简介: #include #include #include using namespace std;string get_num(string &s){ string sa = ""; for(int i = 0; i < s.
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string get_num(string &s){
    string sa = "";
    for(int i = 0; i < s.length(); i++){
        sa.push_back(s[i]);
        int cnt = 1;
        while(i + 1 < s.length() && s[i + 1] == s[i]){
            cnt++;
            i++;
        }
        sa.push_back(cnt + '0');
    }
    return sa;
}

int main( ){
    string s;
    int m;
    cin >> s >> m;
    for(int i = 1; i < m; i++){
        s = get_num(s);
    }
    cout << s << endl;
    return 0;
}
目录
相关文章
|
机器学习/深度学习 自然语言处理 算法框架/工具
Sequence to Sequence学习资料
Sequence to Sequence学习资料
107 0
【1140】Look-and-say Sequence (20分)
【1140】Look-and-say Sequence (20分) 【1140】Look-and-say Sequence (20分)
83 0
HDOJ 1005 Number Sequence
HDOJ 1005 Number Sequence
99 0
|
测试技术
Abstractive Text Summarization Using Sequence-to-Sequence RNNs and Beyond 阅读笔记
- Ramesh Nallapati, Bowen Zhou, Cicero dos Santos; IBM - CoNLL2016 - 这篇文章除了seq2seq,还用了很多的tricks来提升性能,model部分看起来挺多的,LVT在网上搜不到,搜sampled softmax就能搜到了。
2048 0
|
算法 C#
算法题丨Longest Consecutive Sequence
描述 Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
1114 0
1085. Perfect Sequence (25)
#include #include #include using namespace std; int main() { int n; long p; cin >> n >> p; v...
868 0