2 条题解
-
0
按题意直接模拟即可。
AC code:
#include <bits/stdc++.h> using namespace std; int main() { freopen("league.in", "r", stdin); freopen("league.out", "w", stdout); int T; cin >> T; while (T--) { long long n; cin >> n; if (n == 1) { cout << 0 << endl; continue; } long long matches; if (n > 15) { matches = n * (n - 1) / 2; } else { matches = n * (n - 1); } long long days = (matches - 1) * 4 + 1; cout << days << endl; } return 0; } -
0
双循环需要打 场,单循环需要打 场。
场比赛中间有 个 天间隔,因此一共 天。
记得特判 。
#include <bits/stdc++.h> using namespace std; int main() { freopen("league.in", "r", stdin); freopen("league.out", "w", stdout); int T; cin >> T; while (T--) { long long n; cin >> n; if (n == 1) cout << 0 << endl; if (n >= 2 && n <= 15) cout << n * (n - 1) * 4 - 3 << endl; if (n >= 16) cout << n * (n - 1) / 2 * 4 - 3 << endl; } return 0; }
- 1
信息
- ID
- 196
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 1
- 标签
- 递交数
- 100
- 已通过
- 33
- 上传者