#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;
vector<int> insert(int from,int to,int gap){
//cout<<from<<"+++++++"<<to<<"{}{}{}{}"<<gap+1<<endl;
int S=0;
from+=gap+1;
vector<int> res;
while(from+gap+1<=to){
res.push_back(from);
++S;
from+=gap+1;
}
return res;
}
int Fun(const vector<int>& arr,int gap){
vector<int> res;
for(int i=0;i<arr.size()-1;++i){
res.push_back(arr[i]);
auto t=insert(arr[i],arr[i+1],gap);
for(const int k:t){
res.push_back(k);
}
}
res.push_back(arr[arr.size()-1]);
for(const int s:res){
cout<<s<<" ";
}cout<<endl;
return res.size();
}
int main(){
int T,N,gap;
while(cin>>T){
while(T--){
cin>>gap>>N;
int num;
vector<int> arr;
while(N--){
cin>>num;
arr.push_back(num);
}
vector<int> res;
if(arr.empty()){
//res.push_back(1+29/(gap+1));
cout<<(1+29/(gap+1))<<"\n";
}else{
int firstDay=arr[0]-gap-1;
int lastDay=arr[arr.size()-1]+gap+1;
while(firstDay>0){
if(firstDay-gap-1<0){
arr.insert(arr.begin(),firstDay);
}
firstDay-=gap+1;
}
while(lastDay<=30){
if(lastDay+gap+1>30){
arr.push_back(lastDay);
}
lastDay+=gap+1;
}
//res.push_back(Fun(arr,gap));
cout<<Fun(arr,gap)<<"\n";
}
}
}
return 0;
}
网易笔试第三题,线下测试了30多个用例了,为什么还是AC0%
#网易##笔试题目#