3888 2023. 03. 03 14:57:36 Erik_Gepard Sorozat generálás cpp17 Hibás válasz 28/50 4ms 4616 KiB
#include <bits/stdc++.h>
using namespace std;

long long power10(long long x){
    long long ans=1;
    for(long long i=1; i<=x; i++){
        ans*=10;
    }
    return ans;
}

void solve(){
    long long m, x, a, b, n, k, step=0;
    cin>>m>>x>>a>>b>>n>>k;
    vector<long long> v;
    map<long long, long long> found;
    map<long long, long long> db;
    found[x]=0;
    db[x]++;
    while(1){
        v.push_back(x);
        x=x*a+b;
        string s=to_string(x);
        reverse(s.begin(), s.end());
        for(long long i=0; i<4*m-s.size(); i++){
            s+="0";
        }
        //cerr<<s<<" ";
        string ss=s.substr(m, 2*m);
        //cerr<<ss<<" ";
        long long nextx=0;
        for(long long i=0; i<ss.size(); i++){
            nextx+=(ss[i]-'0')*power10(i);
        }
        x=nextx;
        //cerr<<x<<"\n";
        step++;
        if(found[x]){
            cout<<step-found[x]<<"\n";
            //cerr<<found[x]<<"\n";
            for(long long i=found[x]; i<step; i++){
                db[v[i]]=(n-found[x]+1)/(step-found[x]);
            }
            for(long long i=found[x]; i<(n-found[x]+1)%(step-found[x])+found[x]; i++){
                db[v[i]]++;
                //cerr<<v[i]<<" "<<db[v[i]]<<"OK ";
            }
            long long x=0;
            for(pair<long long, long long> p : db){
                //cerr<<p.first<<" "<<p.second<<"\n";
                x+=p.second;
                if(x>k) {
                    cout<<p.first<<"\n";
                    break;
                }
            }
            break;
        }
        db[x]++;
        found[x]=step;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
Részfeladat Összpont Teszt Verdikt Idő Memória
base 28/50
1 Elfogadva 0/0 3ms 1828 KiB
2 Hibás válasz 0/0 3ms 2480 KiB
3 Részben helyes 1/2 2ms 2144 KiB
4 Részben helyes 1/2 3ms 2372 KiB
5 Részben helyes 1/2 2ms 2492 KiB
6 Részben helyes 1/2 2ms 2572 KiB
7 Elfogadva 2/2 3ms 2692 KiB
8 Részben helyes 2/4 3ms 3072 KiB
9 Részben helyes 2/4 3ms 3292 KiB
10 Részben helyes 2/4 3ms 3200 KiB
11 Részben helyes 2/4 3ms 3432 KiB
12 Részben helyes 2/4 3ms 3652 KiB
13 Elfogadva 4/4 4ms 4056 KiB
14 Részben helyes 2/4 4ms 4176 KiB
15 Részben helyes 2/4 3ms 4212 KiB
16 Részben helyes 2/4 4ms 4436 KiB
17 Részben helyes 2/4 4ms 4616 KiB