题解 | #规律数列求和#
规律数列求和
http://www.nowcoder.com/practice/e05d1c142b3d4898be7183289a00ce5f
提交结果:答案正确 运行时间:2ms 占用内存:276KB 使用语言:C++ 用例通过率:100.00%
#include <iostream>
using namespace std;
int main() {
long long sum = 9;
string str = "9";
// write your code here......
for (int i = 1; i < 10; i++) {
str = str + "9";
sum = sum + atol(str.c_str());
}
cout << sum;
return 0;
}