Anh Quan
#include <iostream> #include <cmath> int main() { double a; int n; std::cin >> a >> n; double nps = float(1) / n; double aps = a - floor(a); double diff = 9999; double res = 0; for (int i = 0; i <= n; i++) { //std::cout << fabs((nps * i)) << "\n"; if (fabs((nps * i) - aps) < diff) { diff = fabs((nps * i) - aps); res = floor(a) + (nps * i); } } std::cout.precision(10); std::cout << res; }