QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#739117#9738. Make It Divisibleqianchen06#WA 0ms3784kbC++143.4kb2024-11-12 20:55:092024-11-12 20:55:16

Judging History

你现在查看的是最新测评结果

  • [2024-11-27 18:44:44]
  • hack成功,自动添加数据
  • (/hack/1263)
  • [2024-11-14 09:10:13]
  • hack成功,自动添加数据
  • (/hack/1178)
  • [2024-11-12 20:55:16]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3784kb
  • [2024-11-12 20:55:09]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 1e5 + 10;

int n, k;
int b[maxn];
int a[maxn];
void solve()
{
    cin >> n >> k;
    map<int, int> mp;
    for (int i = 1; i <= n; i++)
    {
        cin >> b[i];
        a[i] = b[i];
    }
    set<int> st;
    int sum = 0;
    if (n == 1)
    {
        cout << k << ' ';
        cout << (1ll + k) * k / 2ll << '\n';
        return;
    }
    for (int i = 1; i < n; i++)
    {
        int r = a[i + 1];
        int l = a[i];
        if (l > r)
            swap(l, r);
        int kx = r / l;

        if (i == 1)
        {
            // if (l == 1)
            // {
            //     int y = r - l;
            //     for (int j = 1; j * j <= y; j++)
            //     {
            //         if (y % j == 0)
            //         {
            //             if (j == 1)
            //             {
            //             }
            //             else
            //             {
            //                 if ((j - 1) <= k && (r + j - 1) % (l + j - 1) == 0)
            //                 {
            //                     st.insert(j - 1);
            //                     sum += j - 1;
            //                 }
            //             }
            //         }
            //         if (y % j == 0 && j * j != y)
            //         {
            //             int le = y / j;
            //             if (le == 1)
            //             {
            //             }
            //             else
            //             {
            //                 if ((le - 1) <= k && (r + le - 1) % (l + le - 1) == 0)
            //                 {
            //                     st.insert(le - 1);
            //                     sum += le - 1;
            //                 }
            //             }
            //         }
            //     }
            // }
            // else
            // {
            for (int j = kx; j >= 2; j--)
            {
                int les = r - l * j;
                if (les <= 0)
                    continue;
                if (les % (j - 1) != 0)
                    continue;
                int y = les / (j - 1);
                if (y <= k)
                {
                    st.insert(y);
                    sum += (y);
                }
            }
            // }
        }
        else
        {
            set<int> stt;
            sum = 0;
            for (int j = kx; j >= 2; j--)
            {
                int les = r - l * j;
                if (les <= 0)
                    continue;
                if (les % (j - 1) != 0)
                    continue;
                int y = les / (j - 1);
                if (y <= k && st.count(y))
                {
                    stt.insert(y);
                    sum += (y);
                }
            }
            swap(stt, st);
        }
    }
    if (st.count(0))
        st.erase(0);
    while (st.upper_bound(k) != st.end())
    {
        sum -= *st.rbegin();
        st.erase(--st.end());
    }
    cout << st.size() << ' ';

    cout << sum << '\n';
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3784kb

input:

3
5 10
7 79 1 7 1
2 1000000000
1 2
1 100
1000000000

output:

3 8
0 0
100 5050

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3564kb

input:

4
201 1000000000
1 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5 2 5...

output:

1 1
1 1
1 1
1 1

result:

wrong answer 1st lines differ - expected: '0 0', found: '1 1'