aboutsummaryrefslogtreecommitdiff
path: root/codeforces/HossamAndCombinatorics
diff options
context:
space:
mode:
Diffstat (limited to 'codeforces/HossamAndCombinatorics')
-rwxr-xr-xcodeforces/HossamAndCombinatorics/mainbin0 -> 45416 bytes
-rw-r--r--codeforces/HossamAndCombinatorics/main.cpp104
-rw-r--r--codeforces/HossamAndCombinatorics/main_input0.txt5
-rw-r--r--codeforces/HossamAndCombinatorics/main_input1.txt3
-rw-r--r--codeforces/HossamAndCombinatorics/main_input2.txt3
-rw-r--r--codeforces/HossamAndCombinatorics/main_input3.txt3
-rw-r--r--codeforces/HossamAndCombinatorics/main_input4.txt3
-rw-r--r--codeforces/HossamAndCombinatorics/main_output0.txt2
-rw-r--r--codeforces/HossamAndCombinatorics/main_output1.txt1
-rw-r--r--codeforces/HossamAndCombinatorics/main_output2.txt1
-rw-r--r--codeforces/HossamAndCombinatorics/main_output3.txt1
-rw-r--r--codeforces/HossamAndCombinatorics/main_output4.txt1
12 files changed, 127 insertions, 0 deletions
diff --git a/codeforces/HossamAndCombinatorics/main b/codeforces/HossamAndCombinatorics/main
new file mode 100755
index 0000000..0a80c3a
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main
Binary files differ
diff --git a/codeforces/HossamAndCombinatorics/main.cpp b/codeforces/HossamAndCombinatorics/main.cpp
new file mode 100644
index 0000000..c9d670e
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main.cpp
@@ -0,0 +1,104 @@
+#include <algorithm>
+#include<bits/stdc++.h>
+using namespace std;
+
+using ll = long long;
+using pi = pair<int, int>;
+using vpi = vector<pi>;
+using vi = vector<int>;
+using vll = vector<long long>;
+using mpii = map<int, int>;
+using mpll = map<ll, ll>;
+using db = long double;
+
+#define pb push_back
+#define all(x) (x).begin(), (x).end()
+#define rall(x) (x).rbegin(), (x).rend()
+#define lb lower_bound
+#define ub upper_bound
+
+const int MOD = (int)1e9 + 7;
+const db PI = acos((db)-1);
+const int dx[4]{1, 0, -1, 0};
+const int dy[4]{0, 1, 0, -1};
+
+//pretty printing
+template<typename K, typename V>
+void printm(const map<K, V> &mp) {
+ cerr << "{" << endl;
+ for (auto p : mp) {
+ cerr << " { " << p.first << " : " << p.second << " }\n";
+ }
+ cerr << "}" << endl;
+}
+template<typename T>
+void printv(const vector<T> &v) {
+ cerr << "[";
+ for (int i = 0; i < v.size(); i++) {
+ if (i == v.size() - 1) {
+ cerr << v[i];
+ } else {
+ cerr << v[i] << ", ";
+ }
+ }
+ cerr << "]\n";
+}
+
+template<typename T>
+void printvv(const vector<vector<T>> &v) {
+ cerr << "[\n";
+ for (auto &vec : v) {
+ cout << " ";
+ printv(vec);
+ }
+ cerr << "]\n";
+}
+void print() {
+ cerr << "\n";
+}
+
+template<typename T, typename... TS>
+void print(T val, TS... vals) {
+ cerr << val << " ";
+ print(vals...);
+}
+
+
+/* stuff you should look for:
+ ---------------------------
+ * special cases (n=1?)
+ * int overflow, array bounds
+ * do smth instead of nothing and stay organized
+ * WRITE STUFF DOWN
+ * DON'T GET STUCK ON ONE APPROACH
+ */
+
+void solve() {
+ ll n;
+ cin >> n;
+ vll v(n), fq(1e5 + 5, 0);
+ for (int i = 0; i < n; i++) {
+ cin >> v[i];
+ fq[v[i]]++;
+ }
+ sort(all(v));
+ ll ans = 0;
+ if (v[0] == v[v.size() - 1]) {
+ ans = n * (n - 1);
+ } else {
+ ans = fq[v[0]] * fq[v[v.size() - 1]] * 2;
+ }
+ cout << ans << '\n';
+}
+
+int main () {
+ ios_base::sync_with_stdio(false);
+ cin.tie(NULL);
+ int tt;
+ cin >> tt;
+ while(tt--) {
+ solve();
+ }
+}
+
+
diff --git a/codeforces/HossamAndCombinatorics/main_input0.txt b/codeforces/HossamAndCombinatorics/main_input0.txt
new file mode 100644
index 0000000..8ba6781
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_input0.txt
@@ -0,0 +1,5 @@
+2
+5
+6 2 3 8 1
+6
+7 2 8 3 2 10
diff --git a/codeforces/HossamAndCombinatorics/main_input1.txt b/codeforces/HossamAndCombinatorics/main_input1.txt
new file mode 100644
index 0000000..2b72911
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_input1.txt
@@ -0,0 +1,3 @@
+1
+5
+2 2 2 10 10 \ No newline at end of file
diff --git a/codeforces/HossamAndCombinatorics/main_input2.txt b/codeforces/HossamAndCombinatorics/main_input2.txt
new file mode 100644
index 0000000..e64d056
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_input2.txt
@@ -0,0 +1,3 @@
+1
+9
+2 2 2 1 1 9 9 10 10 \ No newline at end of file
diff --git a/codeforces/HossamAndCombinatorics/main_input3.txt b/codeforces/HossamAndCombinatorics/main_input3.txt
new file mode 100644
index 0000000..7fd6ee5
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_input3.txt
@@ -0,0 +1,3 @@
+1
+10
+1 1 1 1 1 10 10 10 10 10 \ No newline at end of file
diff --git a/codeforces/HossamAndCombinatorics/main_input4.txt b/codeforces/HossamAndCombinatorics/main_input4.txt
new file mode 100644
index 0000000..b0a2002
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_input4.txt
@@ -0,0 +1,3 @@
+1
+5
+1 1 1 1 1 \ No newline at end of file
diff --git a/codeforces/HossamAndCombinatorics/main_output0.txt b/codeforces/HossamAndCombinatorics/main_output0.txt
new file mode 100644
index 0000000..da7f847
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_output0.txt
@@ -0,0 +1,2 @@
+2
+4
diff --git a/codeforces/HossamAndCombinatorics/main_output1.txt b/codeforces/HossamAndCombinatorics/main_output1.txt
new file mode 100644
index 0000000..3cacc0b
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_output1.txt
@@ -0,0 +1 @@
+12 \ No newline at end of file
diff --git a/codeforces/HossamAndCombinatorics/main_output2.txt b/codeforces/HossamAndCombinatorics/main_output2.txt
new file mode 100644
index 0000000..2edeafb
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_output2.txt
@@ -0,0 +1 @@
+20 \ No newline at end of file
diff --git a/codeforces/HossamAndCombinatorics/main_output3.txt b/codeforces/HossamAndCombinatorics/main_output3.txt
new file mode 100644
index 0000000..c5b431b
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_output3.txt
@@ -0,0 +1 @@
+50 \ No newline at end of file
diff --git a/codeforces/HossamAndCombinatorics/main_output4.txt b/codeforces/HossamAndCombinatorics/main_output4.txt
new file mode 100644
index 0000000..2edeafb
--- /dev/null
+++ b/codeforces/HossamAndCombinatorics/main_output4.txt
@@ -0,0 +1 @@
+20 \ No newline at end of file