Submission #856329

# Submission time Handle Problem Language Result Execution time Memory
856329 2023-10-03T07:01:05 Z Tenis0206 Present (RMI21_present) C++11
8 / 100
2891 ms 600 KB
#include <bits/stdc++.h>

using namespace std;

const int vmax = 100;

struct sir
{
    vector<int> st;
    bool fr[vmax + 5];
    sir()
    {
        memset(fr,false,sizeof(fr));
    }
};

sir get_next(sir s)
{
    for(int val=1;val<=vmax;val++)
    {
        if((s.st.empty() || s.st.back()!=val) && !s.fr[val])
        {
            s.st.push_back(val);
            break;
        }
        if(!s.st.empty() && s.st.back()==val)
        {
            s.st.pop_back();
        }
    }
    sir rez;
    rez.st = s.st;
    for(auto it : rez.st)
    {
        rez.fr[it] = true;
    }
    for(auto a : rez.st)
    {
        for(auto b : rez.st)
        {
            rez.fr[__gcd(a,b)] = true;
        }
    }
    return rez;
}

void solve_test()
{
    int k;
    cin>>k;
    sir rez;
    for(int i=1;i<=k;i++)
    {
        rez = get_next(rez);
    }
    vector<int> r;
    for(int val=1;val<=vmax;val++)
    {
        if(rez.fr[val])
        {
            r.push_back(val);
        }
    }
    cout<<r.size()<<' ';
    for(auto it : r)
    {
        cout<<it<<' ';
    }
    cout<<'\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    //freopen("nr.in","r",stdin);
    //freopen("nr.out","w",stdout);
    int t;
    cin>>t;
    for(int test=1;test<=t;test++)
    {
        solve_test();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 2891 ms 600 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 2891 ms 600 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 2891 ms 600 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Incorrect 2891 ms 600 KB Output isn't correct
8 Halted 0 ms 0 KB -