QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#24093#2945. 1's For AllGeorge_Plover#WA 582ms4284kbC++201.2kb2022-03-26 13:39:342022-04-30 04:55:47

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 04:55:47]
  • Judged
  • Verdict: WA
  • Time: 582ms
  • Memory: 4284kb
  • [2022-03-26 13:39:34]
  • Submitted

answer

#include <bits/stdc++.h>

#define B 18
#define N 100001

using namespace std;

int f[N], n;
bitset<N> g[B];

void update(int &x, int y)
{
    if (y < x)
        x = y;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    f[1] = 1;
    f[2] = 2;
    g[1][1] = g[2][2] = true;

    int cur = 1;

    for (int i = 2; i < N; i++)
    {
        for (int j = 0; j < B; j++)
        {
            if (g[j][i])
            {
                f[i] = j;
                break;
            }
        }

        for (int j = 10; j <= i; j *= 10)
            if (i % j && i / j)
                update(f[i], f[i % j] + f[i / j]);

        if (f[i] > cur)
        {
            cur = f[i];
            // cout << "NEW F " << cur << " I " << i << '\n';
            // cout.flush();
        }

        g[f[i]][i] = true;
        for (int j = 1; j <= cur && f[i] + j < B; j++)
            g[f[i] + j] |= g[j] << i;

        for (int j = 1; j <= i && i * j < N; j++)
            if (f[i] + f[j] < B)
                g[f[i] + f[j]][i * j] = true;

        // cerr << "FINISH " << i << '\n';
    }

    cin >> n;
    // n = 100000;
    cout << f[n] << '\n';
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 576ms
memory: 4284kb

input:

100000

output:

12

result:

ok single line: '12'

Test #2:

score: -100
Wrong Answer
time: 582ms
memory: 4212kb

input:

90909

output:

9

result:

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