fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define mod 1000000007
  4. #define ll long long int
  5. #define endl "\n"
  6. #define pb push_back
  7. #define mp make_pair
  8. #define ut unsigned int
  9. #define ss second
  10. #define ff first
  11. #define vi vector<int>
  12. #define vl vector<ll>
  13. #define lb lower_bound
  14. #define up upper_bound
  15. #define re return
  16. #define yes cout<<"YES"<<endl
  17. #define no cout<<"NO"<<endl
  18.  
  19. ll inline power(ll a, ll b, ll p){
  20. a %= p;
  21. ll ans = 1;
  22. while(b>0){
  23. if(b & 1)
  24. ans = (ans*a)%p;
  25. a = (a*a)%p;
  26. b >>= 1;
  27. }
  28. return ans;
  29. }
  30.  
  31. ll inv(ll n, ll p){
  32. return power(n,p-2, p);
  33. }
  34.  
  35. bool inline isprime(ll n) {
  36. if (n <= 1) return false;
  37. if (n <= 3) return true;
  38. if (n%2 == 0 || n%3 == 0) return false;
  39. for (ll i=5; i*i<=n; i=i+6)
  40. if (n%i == 0 || n%(i+2) == 0)
  41. return false;
  42. return true;
  43. }
  44. int main()
  45. {
  46. ios_base::sync_with_stdio(false);
  47. cin.tie(NULL);
  48. cout.tie(NULL);
  49. int t ;
  50. cin >> t;
  51. while(t--)
  52. {
  53. ll n,x,y,i,j,dif=0,ans=0,i1=n,j1=n,k;
  54. cin>>n>>x>>y;
  55. vl v,v1;
  56. ans=y-x;
  57. dif=ans;
  58. if(n==2){
  59. cout<<x<<" "<<y;
  60. }
  61. else{
  62. for(i=n-1;i>1;i--){
  63. if(ans%i==0){
  64. dif=ans/i;
  65. break;
  66. }
  67. }
  68. v1.pb(x);
  69. for(i=1;i<n;i++){
  70. if(x+i*dif<=y){
  71. v1.pb(x+i*dif);
  72. }
  73. else{
  74. i1=i-1;
  75. break;
  76. }
  77. }
  78. for(j=1;j<n-i1;j++){
  79. if(x-j*dif>0){
  80. v1.pb(x-j*dif);
  81. }
  82. else{
  83. j1=j-1;
  84. break;
  85. }
  86. }
  87. // cout<<j1<<" ";
  88. for(k=1;k<n-i1-j1;k++){
  89. v1.pb(x+(i-1+k)*dif);
  90. }
  91. ll r=v1.size();
  92. for(i=0;i<n;i++)
  93. cout<<v1[i]<<" ";
  94. }
  95. cout<<endl;
  96. }
  97. return 0;
  98. }
Success #stdin #stdout 0s 4300KB
stdin
1
10 3 4
stdout
3 4 2 1 5 6 7 8 9 10