Untitled
user_5379400
plain_text
a month ago
1.3 kB
1
Indexable
Never
#include <iostream> #include <algorithm> #include <time.h> #include <stdlib.h> using namespace std; const int maxn = 1e7; int n; int a[2005]; int f[2005][2005]; int mp[maxn]; int get(int a, int b){ return (double)a / b * 10000000; } int main(){ freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); // cout << 1 << endl << 2000 << endl; // for (int i = 1; i <= 2000; i++) cout << i + 101 << ' '; clock_t start, end; double duration; start = clock(); int t = 1; scanf("%d", &t); for (int testcase = 1; testcase <= t; testcase++){ scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); sort(a + 1, a + 1 + n); long long ans = 0; for (int i = 1; i <= n; i++){ for (int j = i + 1; j <= n; j++){ f[i][j] = get(a[i], a[j]); ans += mp[f[i][j]]; } for (int j = i - 1; j >= 1; j--){ mp[f[j][i]]++; } } for (int i = 1; i <= n; i++){ for (int j = i + 1; j <= n; j++){ mp[f[i][j]] = 0; } } printf("#%d %lld\n", testcase, ans); } end = clock(); duration = (double)(end - start) / CLOCKS_PER_SEC; printf("%f seconds", duration); }
Leave a Comment