2 条题解

  • 0
    @ 2025-11-9 12:24:50

    按题意直接模拟即可。

    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
      @ 2025-9-7 12:13:15

      双循环需要打 n(n−1)n(n-1) 场,单循环需要打 n(n−1)2\dfrac{n(n-1)}{2} 场。

      mm 场比赛中间有 m−1m-1 个 33 天间隔,因此一共 4m−34m-3 天。

      记得特判 n=1n=1。

      #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
      上传者