Submission #144201

# Submission time Handle Problem Language Result Execution time Memory
144201 2019-08-16T09:57:13 Z AldeaDanut Kotrljanje (COCI18_kotrljanje) C++14
126 / 140
1114 ms 9908 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<50000){
        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;
}

Compilation message

kotrljanje.cpp: In function 'int main()':
kotrljanje.cpp:56:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(v[sum].size()==m){
                ~~~~~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1016 KB Output is correct
2 Incorrect 80 ms 5772 KB Expected unsigned integer, but "-2147481657" found
# Verdict Execution time Memory Grader output
1 Correct 57 ms 4360 KB Output is correct
2 Correct 54 ms 4428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 4972 KB Output is correct
2 Correct 57 ms 4588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 4984 KB Output is correct
2 Correct 59 ms 4840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 74 ms 5344 KB Output is correct
2 Correct 142 ms 5732 KB Output is correct
3 Correct 75 ms 5096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 5088 KB Output is correct
2 Correct 71 ms 5344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 1016 KB Output is correct
2 Correct 434 ms 4664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 966 ms 8928 KB Output is correct
2 Correct 663 ms 9796 KB Output is correct
3 Correct 1114 ms 9908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 121 ms 5628 KB Output is correct
2 Correct 550 ms 8644 KB Output is correct
3 Correct 75 ms 5488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 4968 KB Output is correct
2 Correct 69 ms 4432 KB Output is correct