Submission #311943

#TimeUsernameProblemLanguageResultExecution timeMemory
311943colazcyKotrljanje (COCI18_kotrljanje)C++17
0 / 140
2086 ms3720 KiB
#include <cstdio> #include <vector> using namespace std; typedef long long ll; const int maxn = 100000; ll c,d,b,m; inline ll f(ll x){return c * x + d;} inline int cnt(ll x){ int res = 0; while(x){ res += x % b; x /= b; } return res; } vector<int> vec[maxn]; int p = 0; int main(){ // freopen("kotrljanje.in","r",stdin); // freopen("kotrljanje.out","w",stdout); scanf("%lld %lld %lld %lld",&c,&d,&b,&m); for(int i = 0;i < maxn;i++){ int x = cnt(f(i)); if(x < maxn)vec[x].push_back(i); } for(int i = 0;i < maxn;i++) if(m <= vec[i].size()){ for(int j = 0;j < m;j++)printf("%d ",vec[i][j]); return 0; } for(int i = 0;i < maxn;i++) if(vec[i].size() >= 2){ p = i; break; } for(int i = p + 1;i < maxn;i++) if(vec[i].size() >= 2){ int x = vec[i][1] - vec[i][0],y = vec[p][1] - vec[p][0]; if(x < y || (x == y && vec[i].size() > vec[p].size()))p = i; } int delta = vec[p][1] - vec[p][0]; for(int i = 0;i < vec[p].size();i++)printf("%d ",vec[p][i]); m -= vec[p].size(); for(ll now = vec[p].size() + delta;;now += delta){ if(cnt(f(now)) == p){ printf("%lld ",now); m--; } if(!m)break; } fclose(stdin); fclose(stdout); return 0; }

Compilation message (stderr)

kotrljanje.cpp: In function 'int main()':
kotrljanje.cpp:27:8: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   if(m <= vec[i].size()){
      |      ~~^~~~~~~~~~~~~~~~
kotrljanje.cpp:42:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for(int i = 0;i < vec[p].size();i++)printf("%d ",vec[p][i]);
      |                ~~^~~~~~~~~~~~~~~
kotrljanje.cpp:21:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |  scanf("%lld %lld %lld %lld",&c,&d,&b,&m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...