1个回答
展开全部
#include<vector>
int main()
{
vector<int> <a href="https://www.baidu.com/s?wd=num&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3m1mvm1D1n1I9uH6YuA7-0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHTvrHbYPW03nHn1rHmvnW0Y" target="_blank" class="baidu-highlight">num</a>;
int n, temp,k,i;
cin >> k;
if (k <= 0) { cout << -1; return 1; }
for (i = 0; i < 2 * k; i++){
cin >> temp;
<a href="https://www.baidu.com/s?wd=num&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3m1mvm1D1n1I9uH6YuA7-0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHTvrHbYPW03nHn1rHmvnW0Y" target="_blank" class="baidu-highlight">num</a>.push_back(temp);
}
n = 1;
while (1){
temp = <a href="https://www.baidu.com/s?wd=num&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3m1mvm1D1n1I9uH6YuA7-0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHTvrHbYPW03nHn1rHmvnW0Y" target="_blank" class="baidu-highlight">num</a>[2*k - 1] * n + num[ k - 1];
for (i = k - 1; i >= 0; i--){
if ((temp - num[i ]) % num[i+ k] != 0)
break;
}
if (i < 0)break;
n++;
}
cout << temp << endl;
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询