fork download
  1.  
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. #define ll long long
  5. #define pb push_back
  6. #define all(x) x.begin(), x.end()
  7. #include <ext/pb_ds/assoc_container.hpp>
  8. #include <ext/pb_ds/tree_policy.hpp>
  9. using namespace __gnu_pbds;
  10. using namespace std;
  11. template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  12. template <typename T, typename R> using o_map = tree<T, R, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  13.  
  14. #define inf 1e9
  15. #define MOD 1000000007
  16.  
  17. void solve() {
  18. int n , k ;cin >> n >> k ;
  19. if (n == 1 ) {
  20. cout << k << endl ;
  21. return ;
  22. }
  23. n--;
  24. cout << k << " ";
  25. ll numerateur = 0, denominateur =0 ;
  26. vector <int >v ;
  27. for (int i = 1 ; i <=n ; i++) {
  28. if (i == n ) {
  29. cout << k << " ";
  30. continue ;
  31. }
  32. int x = n-i+1 , y = i , plus1 = 0 , plus2 = 0;
  33. while (!(x%2)) {
  34. plus1++;
  35. x/=2;
  36. }
  37. while (!(y%2)) {
  38. plus2++;
  39. y/=2;
  40. }
  41. numerateur+=plus1 ;
  42. denominateur+=plus2 ;
  43. if (numerateur == denominateur) cout << k<< " ";
  44. else cout << 0<< " ";
  45.  
  46. }
  47. cout << endl ;
  48.  
  49. }
  50.  
  51.  
  52. int main() {
  53. ios::sync_with_stdio(false);
  54. cin.tie(0);
  55.  
  56. #ifndef ONLINE_JUDGE
  57. freopen("input.txt", "r", stdin);
  58. freopen("output.txt", "w", stdout);
  59. #endif
  60.  
  61. int t = 1;
  62. cin >> t;
  63. while (t--) {
  64. solve();
  65. }
  66. }
  67.  
Success #stdin #stdout 0s 5268KB
stdin
Standard input is empty
stdout
0