Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #include <ext/pb_ds/detail/standard_policies.hpp>
  4. #include <ext/pb_ds/assoc_container.hpp>
  5. #include <ext/pb_ds/tree_policy.hpp>
  6.  
  7. #pragma comment(linker, "/stack:200000000")
  8. #pragma GCC optimize("Ofast")
  9. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  10. #pragma GCC optimize("unroll-loops")
  11. #pragma GCC optimize("O3")
  12.  
  13. #define F first
  14. #define S second
  15. #define pb push_back
  16. #define ll long long
  17. #define ld long double
  18. #define ull unsigned long long
  19. #define endl '\n'
  20.  
  21. using namespace std;
  22. using namespace __gnu_pbds;
  23.  
  24.  
  25. mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
  26.  
  27.  
  28. const int N = 5e5 + 100;
  29. const int M = 30 + 5;
  30. const int B = 2100;
  31. const int add1 = 39;
  32. const ll per = 1e10;
  33. const ll INF = 1e10;
  34. const int MOD = 998244353;
  35. const int MOD1 = 1e9 + 7;
  36. const int rx[4] = {0, 1, -1, 0};
  37. const int ry[4] = {1, 0, 0, -1};
  38. const char rr[5]= {'5', 'N', 'E', 'S', 'W'};
  39. template <typename T> using ordered_set = tree <T, null_type, less< T >, rb_tree_tag,tree_order_statistics_node_update>;
  40.  
  41. int main() {
  42. ios_base::sync_with_stdio(0);
  43. cin.tie(0);
  44. cout.tie(0);
  45. srand(time(0));
  46. #ifdef LOCAL
  47. freopen("input.txt", "r", stdin);
  48. freopen("output.txt", "w", stdout);
  49. #else
  50. //freopen("input.txt", "r", stdin);
  51. //freopen("output.txt", "w", stdout);
  52. #endif
  53. int kek = 1;
  54. vector < ull > st(21);
  55. for (int i = 0; i <= 20; i++) {
  56. st[i] = kek;
  57. kek *= 3;
  58. }
  59. //cout << (1<<(20)) << endl;
  60. // for (int i = 0; i <= 20; i++) cout << st[i] << endl;
  61. // cout << endl;
  62. int q;
  63. cin >> q;
  64. while (q--) {
  65. ull x;
  66. cin >> x;
  67. ull ans = st[20];
  68. for (int mask = 0; mask < (1<<(20)); mask++) {
  69. ull now = 0;
  70. for (int i = 0; i <= 20; i++) {
  71. if ((mask & (1<<i)) == (1<<i)) now += st[i];
  72. }
  73. if (now >= x) ans = min(ans , now);
  74. }
  75. cout << ans << endl;
  76. }
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement