Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* BISMILLAHIR-RAHMANIR-RAHIM
- ____________________________________
- | |
- | SHANTO_SUST_SWE-19_029 |
- |____________________________________|
- */
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
- #define pb push_back
- #define Pi acos(-1.0)
- #define r0 return 0
- #define endl "\n"
- #define show(x) cout << x << endl
- #define take(x) cin >> x
- #define debug 1
- vector < int > dp;
- void makeDp()
- {
- int bits, num, x, power;
- for(int i = 1; i < 1025; i++) {
- bits = log(i) / log(2) + 1;
- num = 0;
- for(int j = 0; j < 11; j++) {
- x = i & (1 << j);
- if(x) {
- power = 1;
- for(int k = 0; k < j; k++) power *= 3;
- num += power;
- }
- }
- dp.push_back(num);
- }
- }
- int main()
- {
- makeDp();
- int t;
- cin >> t;
- int n;
- while(t--) {
- cin >> n;
- for(auto x : dp) {
- if(x >= n) {
- cout << x << endl;
- break;
- }
- }
- }
- r0;
- }
- //ALHAMDULILLAH
Advertisement
Add Comment
Please, Sign In to add comment