1084 外观数列 (20 分)
作者:互联网
#include <bits/stdc++.h> using namespace std; int main() { int a,b; scanf("%d %d",&a,&b); vector<int> v1; vector<int> v2; v1.push_back(a); b--; while(b--) { v2.clear(); int count = 1; v2.push_back(v1[0]); for(int j=1;j<v1.size();j++) { if(v1[j] == v1[j-1]){ count++; }else{ v2.push_back(count); count=1; v2.push_back(v1[j]); } } v2.push_back(count); v1 = v2; } for(int i=0;i<v1.size();i++) { cout<<v1[i]; } cout<<endl; return 0; }
标签:1084,20,数列,int,back,v1,v2,vector,push 来源: https://www.cnblogs.com/tonyyy/p/10466806.html