QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#739032#9738. Make It Divisibleqianchen06#WA 1ms3864kbC++143.5kb2024-11-12 20:37:432024-11-12 20:37:45

Judging History

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

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

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];
        mp[b[i]]++;
    }
    int fxs = 1;
    for (auto [x, y] : mp)
    {
        a[fxs++] = x;
    }
    n = fxs - 1;
    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];
        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 % (j - 1) != 0)
                        continue;
                    int y = les / (j - 1);
                    if (les == 0)
                        continue;
                    if (y <= k)
                    {
                        st.insert(y);
                        sum += (y);
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
        else
        {
            set<int> stt;
            sum = 0;
            for (int j = kx; j >= 2; j--)
            {
                int les = r - l * j;
                if (les % (j - 1) != 0)
                    continue;
                int y = les / (j - 1);
                if (les == 0)
                    continue;
                if (y <= k && st.count(y))
                {
                    stt.insert(y);
                    sum += (y);
                }
                else
                {
                    break;
                }
            }
            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;
}

详细

Test #1:

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

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: 0
Accepted
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:

0 0
0 0
0 0
0 0

result:

ok 4 lines

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3864kb

input:

500
4 1000000000
8 14 24 18
4 1000000000
17 10 18 14
4 1000000000
6 17 19 19
4 1000000000
15 14 15 25
4 1000000000
16 16 5 25
4 1000000000
4 30 20 5
4 1000000000
11 4 23 9
4 1000000000
14 25 13 2
4 1000000000
18 18 1 15
4 1000000000
22 22 22 28
4 1000000000
15 17 17 10
4 1000000000
22 14 13 25
4 100...

output:

0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
...

result:

wrong answer 178th lines differ - expected: '1 2', found: '0 0'