Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define pb push_back
- #define F first
- #define S second
- #define sq(x) (x) * (x)
- #define ins insert
- #define mp make_pair
- #define ll long long
- #define bit __builtin_popcount
- #define all(x) x.begin(),x.end()
- #define eb emplace_back
- #define ub upper_bound
- #define lb lower_bound
- #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
- #define er erase
- using namespace std;
- const int N = 5555, mod = 1e9 + 7;
- const double EPS = 1e-7;
- const int INF = 2e9;
- const int base = 500;
- const int dx[] = {1, -1, 0, 0};
- const int dy[] = {0, 0, 1, -1};
- int x[11111];
- main() {
- file("cycle");
- ios;
- int t;
- cin >> t;
- while (t--) {
- int n, a, b;
- cin >> n >> a >> b;
- for (int i = 1; i <= n; ++i) {
- cin >> x[i];
- }
- int num = 0;
- for (int i = 1; i <= n; ++i) {
- for (int j = i + 1; j <= n; ++j) {
- if (x[i] == a && x[j] == b) {
- ++num;
- }
- }
- }
- int den = n * n;
- int g = __gcd(num, den);
- num /= g;
- den /= g;
- if (num == den || !num) {
- cout << num << "\n";
- continue;
- }
- cout << num << "/" << den << "\n";
- }
- return 0;
- }
- /// 243368KZ
- /**
- 1 <= T <= 1000
- 1 <= N <= 10^5
- 1 <= x <= N
- T * N <= 10^7
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement