File tree Expand file tree Collapse file tree 1 file changed +116
-0
lines changed Expand file tree Collapse file tree 1 file changed +116
-0
lines changed Original file line number Diff line number Diff line change 1+ #include < bits/stdc++.h>
2+
3+ #define int long long
4+ #define double long double
5+ #define ff first
6+ #define ss second
7+ #define endl ' \n '
8+ #define ii pair<int , int >
9+ #define mp make_pair
10+ #define mt make_tuple
11+ #define DESYNC \
12+ ios_base::sync_with_stdio (false ); \
13+ cin.tie(0 ); \
14+ cout.tie(0 )
15+ #define pb push_back
16+ #define vi vector<int >
17+ #define vii vector<ii>
18+ #define all (x ) x.begin(), x.end()
19+ #define EPS 1e-9
20+ #define INF 1e18
21+ #define ROOT 1
22+ #define M 1000000007
23+ #define curtime chrono::steady_clock::now ().time_since_epoch().count
24+ #define rep (i, beg, n, s ) for (int i = beg; i < n; i += s)
25+ const double PI = acos(-1 );
26+
27+ using namespace std ;
28+
29+ inline int mod (int n, int m = M)
30+ {
31+ int ret = n % m;
32+ if (ret < 0 )
33+ ret += m;
34+ return ret;
35+ }
36+
37+ int exp (int n, int k)
38+ {
39+ if (k == 0 )
40+ return 1 ;
41+ if (k == 1 )
42+ return n;
43+ int ax = exp (n, k / 2 );
44+ ax = mod (ax * ax);
45+ if (k % 2 )
46+ ax = mod (ax * n);
47+ return ax;
48+ }
49+
50+ int gcd (int a, int b)
51+ {
52+ if (a == 0 )
53+ return b;
54+ else
55+ return gcd (b % a, a);
56+ }
57+ // #define MULTIPLE_TEST_CASE
58+ void solution ()
59+ {
60+ map<ii, int > m;
61+ int ans = 0 ;
62+ int n;
63+ cin >> n;
64+ for (int i = 0 ; i < n; i++)
65+ {
66+ double x;
67+ cin >> x;
68+ ii frac (round (x * 1e9 ), 1e9 );
69+ int g = gcd (frac.ff , frac.ss );
70+ frac.ff /= g;
71+ frac.ss /= g;
72+ int pot5 = 0 ;
73+ int pot2 = 0 ;
74+ while (frac.ff % 2 == 0 )
75+ {
76+ frac.ff /= 2 ;
77+ pot2++;
78+ }
79+ while (frac.ff % 5 == 0 )
80+ {
81+ frac.ff /= 5 ;
82+ pot5++;
83+ }
84+ while (frac.ss % 2 == 0 )
85+ {
86+ frac.ss /= 2 ;
87+ pot2--;
88+ }
89+ while (frac.ss % 5 == 0 )
90+ {
91+ frac.ss /= 5 ;
92+ pot5--;
93+ }
94+ ii cur (pot5, pot2);
95+ for (auto p : m)
96+ {
97+ if (p.ff .ff + cur.ff >= 0 && p.ff .ss + cur.ss >= 0 )
98+ ans += p.ss ;
99+ }
100+ m[cur]++;
101+ }
102+ cout << ans << endl;
103+ }
104+
105+ int32_t main ()
106+ {
107+ DESYNC;
108+ mt19937 rng (chrono::steady_clock::now ().time_since_epoch ().count ());
109+ int t = 1 ;
110+ #ifdef MULTIPLE_TEST_CASE
111+ cin >> t;
112+ #endif
113+ while (t--)
114+ solution ();
115+ }
116+
You can’t perform that action at this time.
0 commit comments