/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 400.0 KiB
#2 Wrong Answer 59ms 788.0 KiB

Code

/**
 *    author:   Binoy Barman
 *    created:  2025-04-06 21:35:44
**/

#include<bits/stdc++.h>
#ifdef LOCAL
#include "algo/debug.h"
#else
#define dbg(...) 42
#endif
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = 2e9;

#define int long long
#define nl '\n'
#define all(v) v.begin(), v.end()
#define clg(x) (32 - __builtin_clz(x))
#define Testcase_Handler int tts, tc = 0; cin >> tts; hell: while(tc++ < tts)
#define uniq(v) sort(all(v)), v.resize(distance(v.begin(), unique(v.begin(), v.end())))
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;
template<typename T> istream& operator>>(istream& in, vector<T>& a) {for(auto &x : a) in >> x; return in;};
template<typename A, typename B> istream& operator>>(istream& in, pair<A, B>& p) {in >> p.first >> p.second; return in;};
template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {bool first = true;for(auto &x : a) {if(!first) out << ' ';first = false;out << x;}return out;};

namespace Dark_Lord_Binoy {
inline void init() {
    ios::sync_with_stdio(false); 
    cin.tie(nullptr);

    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
}

int32_t main() {
    Dark_Lord_Binoy::init();
    Testcase_Handler {
        int n;
        cin >> n;
        int two = 1;
        int sum = (n * (n + 1)) / 2LL;
        int e1 = 1;
        while(two * 2LL <= sum) {
            two *= 2LL;
            e1++;
        }
        vector<pair<int, int>> ops;
        ops.push_back({e1, 1});
        int three = 1, e2 = 0;
        while(e2 + 1 < e1 && (three * 3LL) + (two / 2) <= sum) {
            two /= 2LL;
            e1--;
            e2++;
            three *= 3LL;
            ops.push_back({e1, e2});
        }
        int val = two + three;
        dbg(sum, val);
        dbg(two, e1, three, e2);
        int ans = 0;
        for(auto it : ops) {
            ans = max(ans, it.first * it.second);
        }
        cout << ans << nl;
    }

    dbg(_Time_);
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1180 Maximum Divisor
Contest
Brain Booster #9
Language
C++17 (G++ 13.2.0)
Submit At
2025-04-06 17:03:42
Judged At
2025-04-06 17:03:42
Judged By
Score
0
Total Time
59ms
Peak Memory
788.0 KiB