中文版
1 #include<iostream> 2 using namespace std; 3 int main(){ 4 int d,n; 5 cin>>d>>n; 6 string ans; 7 ans += d+‘0‘; 8 for(int i = 0; i < n-1;++i){ 9 string temp; 10 for(int j = 0; j < ans.size();++j){ 11 int cnt = 1; 12 while(j+1 < ans.size()&& ans[j] == ans[j+1]){ 13 ++j; 14 ++cnt; 15 } 16 temp += ans[j]; 17 temp += cnt + ‘0‘; 18 } 19 ans = temp; 20 } 21 cout<<ans; 22 return 0; 23 }
原文:https://www.cnblogs.com/keep23456/p/12493368.html