搜狐第一道

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zlb872551601/article/details/77657699

笔试的时候,头脑比较混乱,几个变量一直绕来绕去,笔试完,15分钟感觉就能理清楚,

事后牛客上再检测吧

#include <iostream>



using namespace std;
#include <vector>
int main()
{
int n,m;
while (cin>>n>>m)
{
int temp;
vector<int> data;
for (int i = 0; i < m;i++)
{
cin >> temp; 
data.push_back(temp);
}
vector<int>ans;
ans.push_back(data[0]);
int type = 0;
int k = 0;
while (k < 2*n)
         {
int len = ans[type];
if (k==0)
{
ans.pop_back();
}
for (int j = k; j <= k + len - 1;j++)
{
ans.push_back(data[(type)%data.size()]);
}
type++;
k = k + len;
         }
for (int i = 0; i < n;i++)
{
cout << ans[i] << endl;
}


}
return 0;
}

猜你喜欢

转载自blog.csdn.net/zlb872551601/article/details/77657699