Submission #144061

# Submission time Handle Problem Language Result Execution time Memory
144061 2019-08-15T22:38:52 Z AldeaDanut Kotrljanje (COCI18_kotrljanje) C++14
126 / 140
2000 ms 2908 KB
#include <iostream>
using namespace std;

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

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

    x=3;
    for(i=1;;i++){
        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;
    for(i=1;m;i++){
        n=c*x+d;
        sum=0;
        while(n){
            sum+=n%b;
            n/=b;
        }

        if(sum==sol){
            m--;
            cout<<x<<" ";
        }
        x+=b-1;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 101 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 2296 KB Output is correct
2 Correct 68 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 2428 KB Output is correct
2 Correct 72 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 2556 KB Output is correct
2 Correct 70 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 2764 KB Output is correct
2 Correct 220 ms 2228 KB Output is correct
3 Correct 99 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 2736 KB Output is correct
2 Correct 89 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 436 KB Output is correct
2 Correct 814 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1816 ms 1784 KB Output is correct
2 Correct 1203 ms 2168 KB Output is correct
3 Execution timed out 2055 ms 2184 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 164 ms 2264 KB Output is correct
2 Correct 993 ms 2168 KB Output is correct
3 Correct 94 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 2792 KB Output is correct
2 Correct 89 ms 2296 KB Output is correct