Submission #144196

# Submission time Handle Problem Language Result Execution time Memory
144196 2019-08-16T09:54:38 Z AldeaDanut Kotrljanje (COCI18_kotrljanje) C++14
126 / 140
2000 ms 3704 KB
#include <iostream>
#include <vector>
using namespace std;

long long n,c,d,b,m,x,i,sum,sol;
int f[30000];
vector <int> v[30000];

int main(){
    cin>>c>>d>>b>>m;

    ///if(m<500){
        x=3;
        while(true){
            n=c*x+d;
            sum=0;
            while(n){
                sum+=n%b;
                n/=b;
            }
            f[sum]++;

            if(f[sum]==m){
                sol=sum;
                break;
            }
            x+=b-1;
        }

        x=3;
        while(m){
            n=c*x+d;
            sum=0;
            while(n){
                sum+=n%b;
                n/=b;
            }

            if(sum==sol){
                cout<<x<<" ";
                m--;
            }
            x+=b-1;
        }
    /*}else{
        x=3;
        while(true){
            n=c*x+d;
            sum=0;
            while(n){
                sum+=n%b;
                n/=b;
            }
            v[sum].push_back(x);

            if(v[sum].size()==m){
                sol=sum;
                break;
            }
            x+=b-1;
        }

        for(i=0;i<m;i++)
            cout<<v[sol][i]<<" ";
    }*/

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1144 KB Output is correct
2 Correct 98 ms 3704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 3064 KB Output is correct
2 Correct 66 ms 3156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 3192 KB Output is correct
2 Correct 70 ms 3192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 83 ms 3324 KB Output is correct
2 Correct 72 ms 3320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 3448 KB Output is correct
2 Correct 223 ms 2892 KB Output is correct
3 Correct 100 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 3492 KB Output is correct
2 Correct 87 ms 3512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 1144 KB Output is correct
2 Correct 805 ms 1848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1823 ms 2568 KB Output is correct
2 Correct 1204 ms 2848 KB Output is correct
3 Execution timed out 2058 ms 2768 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 162 ms 2936 KB Output is correct
2 Correct 987 ms 3064 KB Output is correct
3 Correct 95 ms 3448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 3448 KB Output is correct
2 Correct 91 ms 2936 KB Output is correct