Files
python/TangDou/LuoGuBook/L4_12_1.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

14 lines
300 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
//正确的代码,消除了浮点数的误差
//方法将所有数字乘10然后累加。
int main() {
int n;
double s = 0;
cin >> n;
for (int i = 1; i <= 10 * n - 1; i++) s += i;
cout << s / 10;
return 0;
}