Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define pb push_back
  3. #define F first
  4. #define S second
  5. #define sq(x) (x) * (x)
  6. #define ins insert
  7. #define mp make_pair
  8. #define ll long long
  9. #define bit __builtin_popcount
  10. #define all(x) x.begin(),x.end()
  11. #define eb emplace_back
  12. #define ub upper_bound
  13. #define lb lower_bound
  14. #define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  15. #define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
  16. #define er erase
  17.  
  18. using namespace std;
  19.  
  20. const int N = 5555, mod = 1e9 + 7;
  21. const double EPS = 1e-7;
  22. const int INF = 2e9;
  23. const int base = 500;
  24. const int dx[] = {1, -1, 0, 0};
  25. const int dy[] = {0, 0, 1, -1};
  26.  
  27. int x[11111];
  28. main() {
  29. file("cycle");
  30. ios;
  31. int t;
  32. cin >> t;
  33. while (t--) {
  34. int n, a, b;
  35. cin >> n >> a >> b;
  36. for (int i = 1; i <= n; ++i) {
  37. cin >> x[i];
  38. }
  39. int num = 0;
  40. for (int i = 1; i <= n; ++i) {
  41. for (int j = i + 1; j <= n; ++j) {
  42. if (x[i] == a && x[j] == b) {
  43. ++num;
  44. }
  45. }
  46. }
  47. int den = n * n;
  48. int g = __gcd(num, den);
  49. num /= g;
  50. den /= g;
  51. if (num == den || !num) {
  52. cout << num << "\n";
  53. continue;
  54. }
  55. cout << num << "/" << den << "\n";
  56. }
  57. return 0;
  58. }
  59. /// 243368KZ
  60. /**
  61. 1 <= T <= 1000
  62. 1 <= N <= 10^5
  63. 1 <= x <= N
  64. T * N <= 10^7
  65. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement