C - Yet Another Array Restoration
先求出最小的整数公差,再求出第一项,最后求整个等差数列
#include <iostream>
using namespace std;
int n,x,y;
int main () {
int T;
cin >> T;
while (T--) {
cin >> n >> x >> y;
int t = n-1;
while (true) {
if ((y-x)%t == 0) break;
t--;
}
t = (y-x)/t;
x = max ((x-1)%t+1,y-t*(n-1));
while (n--) {
cout << x << ' ';
x += t;
}
cout << endl;
}
return 0;
}

浙公网安备 33010602011771号