思路:
构造

实现:

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 int main()
 4 {
 5     int n, m;
 6     cin >> n >> m;
 7     cout << "100003 100003" << endl;
 8     for (int i = 0; i < n - 2; i++)
 9     {
10         cout << i + 1 << " " << i + 2 << " " << 1 << endl;
11     }
12     cout << n - 1 << " " << n << " " << 100005 - n << endl;
13     int cnt = 0;
14     for (int i = 1; i <= n; i++)
15     {
16         for (int j = i + 2; j <= n; j++)
17         {
18             if (cnt >= m - n + 1) break;
19             cout << i << " " << j << " 1000000000" << endl;
20             cnt++;
21         }
22     }
23     return 0;
24 }

 

相关文章:

  • 2022-12-23
  • 2021-08-26
  • 2022-02-09
  • 2021-12-29
  • 2021-12-11
  • 2021-07-09
猜你喜欢
  • 2022-12-23
  • 2021-07-16
  • 2021-12-08
  • 2022-12-23
  • 2021-12-05
  • 2021-07-07
相关资源
相似解决方案