#include <iostream> #include <cmath> using namespace std; const long long great = 1000000007; bool isSame(long long a, long long b, long long c) { if (a == b && b == c) return true; if (a == b) return false; if (b == c) return false; if (c == a) return false; return true; } int main() { int T; cin >> T; for (int i = 0; i < T; ++i) { long long N; cin >> N; long long sum = 0; for (long long A = 1; A <= N; ++A) for (long long B = 1; B <= N; ++B) for (long long C = 1; C <= N; ++C) { if (!isSame(A, B, C)) continue; long long temp = 0; temp = (N - A + 1) * (N - B + 1) * (N - C + 1); sum = (sum + temp) % great; } cout << "Case " << i + 1 << ": " << sum << endl;; } return 0; }
注意了 C++中的 unsigned long long int 是64Bit 也就是18位,
时间: 2024-11-06 07:40:43