33,311
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string turn(string s);
int main()
{
int d,N;
cin>>d>>N;
string ans;
string s;
for(int i=1;i<=N;i++){
if(i!=1){
ans=s;
s=turn(ans);
}
else{
string temp;
temp=temp+(char)('0'+d);
s=temp;
}
}
cout<<s<<endl;
return 0;
}
string turn(string s)
{
unsigned int i=2;
string t;
while(i<=s.size()){
int j=1;
int sign=0;
int k=i;
while(i<=s.size()&&s[i-1]==s[i-2]){
i++;
j++;
sign=1;
}
i++;
t=t+s[k-2];
t=t+(char)('0'+j);
}
if(i==s.size()+1&&s[i-2]!=s[i-3]){
t=t+s[s.size()-1];
t=t+'1';
}
return t;
}
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string turn(string s);
int main()
{
int d,N,len;
int i,j,k;
string ans,s;
cin >> s >> N;
//cin>>d>>N;
//s = (char)('0'+d);
for(i=1;i<N;i++){
ans = "";
len = s.length();
for(j = 0; j < len;)
{
ans += s[j];
for(k = j; k < len - 1; k++)
{
if(s[k]!= s[k+1]) break;
}
ans += (char)('0'+ k - j + 1);
j = k+1;
}
s = ans;
}
cout<<s<<endl;
return 0;
}
if(i==s.size()+1&&s[i-2]!=s[i-3]){
t=t+s[s.size()-1];
t=t+'1';
}
#include <iostream>
#include <vector>
#include <string>
using namespace std;
string turn(string s);
int main()
{
int d,N;
cin>>d>>N;
string ans;
string s;
for(int i=1;i<=N;i++){
if(i!=1){
ans=s;
s=turn(ans);
}
else{
string temp;
temp=temp+(char)('0'+d);
s=temp;
}
}
cout<<s<<endl;
return 0;
}
string turn(string s)
{
unsigned int i=2;
string t;
if(s.size()==1)
{
t = s + "1";
}
else
{
while(i<=s.size()){
int j=1;
int sign=0;
int k=i;
while(i<=s.size()&&s[i-1]==s[i-2]){
i++;
j++;
sign=1;
}
i++;
t=t+s[k-2];
t=t+(char)('0'+j);
}
if(i==s.size()+1&&s[i-2]!=s[i-3]){
t=t+s[s.size()-1];
t=t+'1';
}
}
return t;
}