Submission #144212

# Submission time Handle Problem Language Result Execution time Memory
144212 2019-08-16T10:02:14 Z AldeaDanut Kotrljanje (COCI18_kotrljanje) C++14
126 / 140
1101 ms 9920 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(b<5000 && c>10000){
        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 1144 KB Output is correct
2 Incorrect 80 ms 5772 KB Expected unsigned integer, but "-2147481657" found
# Verdict Execution time Memory Grader output
1 Correct 56 ms 4360 KB Output is correct
2 Correct 54 ms 4456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 4844 KB Output is correct
2 Correct 58 ms 4788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 4932 KB Output is correct
2 Correct 60 ms 4796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 81 ms 5352 KB Output is correct
2 Correct 143 ms 5680 KB Output is correct
3 Correct 75 ms 5096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 5084 KB Output is correct
2 Correct 68 ms 5344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 1460 KB Output is correct
2 Correct 439 ms 4684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 967 ms 8956 KB Output is correct
2 Correct 665 ms 9920 KB Output is correct
3 Correct 1101 ms 9792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 5632 KB Output is correct
2 Correct 575 ms 8408 KB Output is correct
3 Correct 76 ms 5432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 4972 KB Output is correct
2 Correct 70 ms 4556 KB Output is correct