Language: C++

#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll A[N];
  string tmp, tmp1;
  bool find;
  bool B[N];
  for(ll i=0;i<N;++i) {
    tmp1.clear();
    tmp.clear();
    cin>>tmp;
    for(ll j=0;j<9;++j) tmp.push_back('0');
    find = false;
    for(ll j=0;j<tmp.size();++j) {
      if(tmp[j]=='.') {
        find = true;
        for(ll k=1;k<10;++k) {
          tmp1.push_back(tmp[j+k]);
        }
        break;
      }
    }
    if(!find) {
      for(ll j=0;j<9;++j) tmp.pop_back();
      A[i] = stoll(tmp);
      B[i] = false;
    }
    else {
      if(stoll(tmp1)==0) {
        for(ll j=0;j<9;++j) tmp.pop_back();
        A[i] = stoll(tmp);
        B[i] = false;
      }
      else {
        A[i] = stoll(tmp1);
        B[i] = true;
      }
    }
  }
  ll ans = 0;
  ll num;
  ll twonum[N], fivenum[N];
  ll zeronum = 0;
  ll tmpa;
  for(ll i=0;i<N;++i) {
    if(!B[i]) {
      zeronum++;
      continue;
    }
    tmpa = A[i];
    twonum[i] = 0;
    fivenum[i] = 0;
    while(tmpa%2==0) {
      twonum[i]++;
      tmpa /= 2;
    }
    while(tmpa%5==0) {
      fivenum[i]++;
      tmpa /= 5;
    }
  }
  for(ll i=0;i<N;++i) {
    if(B[i]) continue;
    tmpa = A[i];
    twonum[i] = 0;
    fivenum[i] = 0;
    while(tmpa%2==0) {
      twonum[i]++;
      tmpa /= 2;
    }
    while(tmpa%5==0) {
      fivenum[i]++;
      tmpa /= 5;
    }
  }
  map<ll, ll> amap1, amap2;
  ll two, five;
  for(ll i=0;i<N;++i) {
    if(!B[i]) continue;
    two = 1;
    for(ll j=0;j<=twonum[i];++j) {
      five = 1;
      for(ll k=0;k<=fivenum[i];++k) {
        amap1[two*five]++;
        five *= 5;
      }
      two *= 2;
    }
  }
  for(ll i=0;i<N;++i) {
    if(B[i]) continue;
    two = 1;
    for(ll j=0;j<=twonum[i];++j) {
      five = 1;
      for(ll k=0;k<=fivenum[i];++k) {
        amap2[two*five]++;
        five *= 5;
      }
      two *= 2;
    }
  }
  ll tmpnum;
  for(ll i=0;i<N;++i) {
    tmpnum = 1;
    if(B[i]){
      tmpnum *= pow(2, max(0, 9-twonum[i]));
      tmpnum *= pow(5, max(0, 9-fivenum[i]));
      ans += amap2[tmpnum];
      tmpnum *= 1e8;
      if(A[i]%tmpnum==0) ans += amap1[tmpnum]-1;
      else ans += amap1[tmpnum];
    }
    else {
      tmpnum = 1e9;
      tmpnum /= pow(2, min(9, twonum[i]));
      tmpnum /= pow(5, min(9, fivenum[i]));
      ans += amap1[tmpnum];
      ans += zeronum-1;
    }
    cout<<i<<" "<<ans<<endl;
  }
  cout<<ans/2<<endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:131:27: error: no matching function for call to 'max(int, ll)'
  131 |       tmpnum *= pow(2, max(0, 9-twonum[i]));
      |                        ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:131:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  131 |       tmpnum *= pow(2, max(0, 9-twonum[i]));
      |                        ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:131:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  131 |       tmpnum *= pow(2, max(0, 9-twonum[i]));
      |                        ~~~^~~~~~~~~~~~~~~~
a.cc:132:27: error: no matching function for call to 'max(int, ll)'
  132 |       tmpnum *= pow(5, max(0, 9-fivenum[i]));
      |                        ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:132:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  132 |       tmpnum *= pow(5, max(0, 9-fivenum[i]));
      |                        ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:132:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  132 |       tmpnum *= pow(5, max(0, 9-fivenum[i]));
      |                        ~~~^~~~~~~~~~~~~~~~~
a.cc:140:27: error: no matching function for call to 'min(int, ll&)'
  140 |       tmpnum /= pow(2, min(9, twonum[i]));
      |                        ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:140:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  140 |       tmpnum /= pow(2, min(9, twonum[i]));
      |                        ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:140:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  140 |       tmpnum /= pow(2, min(9, twonum[i]));
      |                        ~~~^~~~~~~~~~~~~~
a.cc:141:27: error: no matching function for call to 'min(int, ll&)'
  141 |       tmpnum /= pow(5, min(9, fivenum[i]));
      |                        ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:141:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
  141 |       tmpnum /= pow(5, min(9, fivenum[i]));
      |                        ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:141:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  141 |       tmpnum /= pow(5, min(9, fivenum[i]));
      |                        ~~~^~~~~~~~~~~~~~~