Submission #311943

# Submission time Handle Problem Language Result Execution time Memory
311943 2020-10-12T03:34:52 Z colazcy Kotrljanje (COCI18_kotrljanje) C++17
0 / 140
2000 ms 3720 KB
#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

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 time Memory Grader output
1 Execution timed out 2078 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2048 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2025 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2062 ms 3456 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2032 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 3192 KB Output is correct
2 Execution timed out 2077 ms 3720 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 2076 ms 3260 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2076 ms 3200 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2086 ms 3328 KB Time limit exceeded
2 Halted 0 ms 0 KB -