Submission #144194

# Submission time Handle Problem Language Result Execution time Memory
144194 2019-08-16T09:53:03 Z AldeaDanut Kotrljanje (COCI18_kotrljanje) C++14
126 / 140
1092 ms 9944 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<300){
        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 1272 KB Output is correct
2 Incorrect 82 ms 5776 KB Expected unsigned integer, but "-2147481657" found
# Verdict Execution time Memory Grader output
1 Correct 56 ms 4360 KB Output is correct
2 Correct 55 ms 4456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 4888 KB Output is correct
2 Correct 57 ms 4588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 5036 KB Output is correct
2 Correct 59 ms 4712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 5348 KB Output is correct
2 Correct 141 ms 5604 KB Output is correct
3 Correct 75 ms 5096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 5208 KB Output is correct
2 Correct 70 ms 5344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1400 KB Output is correct
2 Correct 433 ms 4656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 975 ms 9160 KB Output is correct
2 Correct 664 ms 9944 KB Output is correct
3 Correct 1092 ms 9904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 5592 KB Output is correct
2 Correct 547 ms 8528 KB Output is correct
3 Correct 74 ms 5480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 4972 KB Output is correct
2 Correct 69 ms 4556 KB Output is correct