CSES - Datatähti 2022 alku - Results
Submission details
Task:Karkit
Sender:mbezirgan
Submission time:2021-10-04 16:51:06 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:15:20: error: 'floor' was not declared in this scope
  int result = (int)floor((n / (float)a));
                    ^~~~~
input/code.cpp:15:20: note: suggested alternative: 'float'
  int result = (int)floor((n / (float)a));
                    ^~~~~
                    float

Code

#include <iostream>

int main()
{
	int n, a, b;

	std::cin >> n;
	std::cin >> a;
	std::cin >> b;

	// Evaluate witch one is cheaper and make a it
	a = a < b ? a : b;

	// Look how many candies can be bought with the cheapest price
	int result = (int)floor((n / (float)a));

	std::cout << result;
}