1 条题解
-
1
C++ :
#include <bits/stdc++.h> using namespace std; int n; int a, b, c, d, e, f; int ans = 0; // 求环状的差值 int fun(int x, int y) { if (abs(x - y) < n - abs(x - y)) { return abs(x - y); } else { return n - abs(x - y); } } int main() { cin >> n; cin >> a >> b >> c; cin >> d >> e >> f; // 枚举3个数的所有的可能: i, j, k for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= n; k++) { // 如果和一组数“接近”,则符合要求 if (fun(i, a) <= 2 && fun(j, b) <= 2 && fun(k, c) <= 2 || fun(i, d) <= 2 && fun(j, e) <= 2 && fun(k, f) <= 2) { ans++; } } } } cout << ans; return 0; }
信息
- ID
- 1028
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 10
- 标签
- 递交数
- 3
- 已通过
- 3
- 上传者