/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 540.0 KiB
#2 Time Exceeded ≥2599ms ≥596.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define trace(x) cerr << #x << ": " << x << '\n'
int sum(int n)
{

    return (n * (n + 1)) / 2;
}
int divcnt(int n)
{
    int cnt = 0;
    for (int i = 1; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            cnt++;
            if (i != n / i)
                cnt++;
        }
    }
    return cnt;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // int mx = 0;
    // for (int i = 1; i <= 100; i++)
    // {
    //     int s = sum(i);
    //     mx = max(mx, divcnt(s));
    //     cout << i << " " << mx << endl;
    // }
    int t;
    cin >> t;
    while (t--)
    {
        int n, mx = 0, ans = 0;
        cin >> n;
        for (int j = n, i = 0; i < 10 and j >= 0; j--, i++)
        {
            int s = sum(j);
            int cnt = divcnt(s);
            if (cnt > mx)
            {
                mx = cnt;
                ans = j;
            }
        }
        cout << ans << '\n';
    }

    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:35:26
Judged At
2025-04-06 17:35:26
Judged By
Score
0
Total Time
≥2599ms
Peak Memory
≥596.0 KiB