| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 141431 | Kevin | 直线分割圆 | C++ | Accepted | 0 MS | 272 KB | 549 | 2025-12-23 19:30:32 |
#include <iostream> using namespace std; int main() { unsigned long long n; cin >> n; // 使用公式:R = n*(n+1)/2 + 1 // 注意:n可能很大,需要防止溢出 if (n % 2 == 0) { // 先除以2再乘,避免溢出 unsigned long long result = (n / 2) * (n + 1) + 1; cout << result << endl; } else { // n是奇数,先乘n+1(偶数) unsigned long long result = n * ((n + 1) / 2) + 1; cout << result << endl; } return 0; }