ninininininini @ 2024-07-06 22:55:40
#include <iostream>
#include <iomanip>
#define cin std::cin
#define cout std::cout
#define endl std::endl
int main() {
int n, k;
cin >> n >> k;
long double sum_A, sum_B, num_A = 0, num_B = 0;
for (int i = 1; i <= n; i++) {
if ( i % k == 0 ) sum_A += i + 0.0, num_A++;
else sum_B += i + 0.0, num_B++;
}
cout << std::fixed << std::setprecision(1);
cout << sum_A / num_A << " " << sum_B / num_B << endl;
return 0;
}
by FluoroantimonicAcid @ 2024-07-07 01:39:49
@ninininininini 输出的是 nan
吧,说明里面有 0.0 / 0.0
的操作。
#include <iostream>
int main() {
double x = 0.0 / 0.0;
std::cout << x;
}
输出:
nan
by ninininininini @ 2024-07-14 10:35:12
@FluoroantimonicAcid okok谢谢 这个还真没见过
by Leaf59 @ 2024-07-27 12:02:36
试问这么复杂干嘛?
using namespace std;