Files
python/TangDou/LuoGuBook/L4_12_1.cpp

14 lines
300 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#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;
}