Submission #144059

# Submission time Handle Problem Language Result Execution time Memory
144059 2019-08-15T22:31:52 Z AldeaDanut Kotrljanje (COCI18_kotrljanje) C++14
126 / 140
2000 ms 2936 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;;i++){
        n=c*x+d;
        sum=0;
        while(n){
            sum+=n%b;
            n/=b;
        }

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

        if(m==0)
            break;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 100 ms 2920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 2396 KB Output is correct
2 Correct 67 ms 2424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 2512 KB Output is correct
2 Correct 69 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 2680 KB Output is correct
2 Correct 71 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 2696 KB Output is correct
2 Correct 222 ms 2184 KB Output is correct
3 Correct 99 ms 2684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 2860 KB Output is correct
2 Correct 88 ms 2936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 484 KB Output is correct
2 Correct 805 ms 1128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1839 ms 1892 KB Output is correct
2 Correct 1218 ms 2168 KB Output is correct
3 Execution timed out 2048 ms 2132 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 161 ms 2296 KB Output is correct
2 Correct 986 ms 2396 KB Output is correct
3 Correct 94 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 2680 KB Output is correct
2 Correct 91 ms 2296 KB Output is correct