Problem p02588 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (ll i = 0; i < (ll)n; ++i)
#define REPN(i, m, n) for (ll i = m; i < (ll)n; ++i)
#define REVREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VC vector<char>
#define VVC vector<vector<char>>
#define INF (ll)2e9
#define INF_LL 1LL << 60
// #define MOD             998244353
#define MOD 1000000007

ll Ceil(ll val, ll div) { return (val + div - 1) / div; }
ll CeilN(ll val, ll div) { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n) { return (x - x % n); }
bool IsOdd(ll x) { return ((x & 1) == 1); }
bool IsEven(ll x) { return ((x & 1) == 0); }
template <class T> bool chmax(T &a, T b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a >= b) {
    a = b;
    return 1;
  }
  return 0;
}

/* baseのべき乗を求める */
template <class T> T getPower(int exponet, int base) {
  T ans = 1;
  for (int i = 0; i < exponet; i++) {
    ans *= base;
  }
  return ans;
}

void Solve() {
  ll N;
  cin >> N;
  vector<string> A(N);
  REP(i, N) cin >> A[i];

  vector<P> primePair(N);

  auto getSosuuPari = [](ll val) {
    ll tmp;
    tmp = val;
    P res = {0, 0};

    while (tmp % 2 == 0) {
      tmp /= 2;
      res.first++;
    }

    tmp = val;
    while (tmp % 5 == 0) {
      tmp /= 5;
      res.second++;
    }

    return res;
  };

  REP(i, N) {
    auto &one = A[i];
    auto pos = one.find('.');

    ll topVal;
    ll divVal;
    if (pos == string::npos) {
      divVal = 1;
      topVal = stoll(one);
    } else {
      ll strLen = one.size() - pos - 1;
      string join = one.substr(0, pos) + one.substr(pos + 1);
      divVal = getPower<ll>(strLen, 10);
      topVal = stoll(join.c_str());
    }
    P topPrime = getSosuuPari(topVal);
    P divPrime = getSosuuPari(divVal);
    primePair[i].first = topPrime.first - divPrime.first;
    primePair[i].second = topPrime.second - divPrime.second;
  }

  ll geta = 50;
  VVL matrix(100, VL(100, 0));
  for (auto &one : primePair) {
    matrix[one.first + geta][one.second + geta]++;
  }

  ll ans = 0;
  REP(idx, N) {
    auto &one = primePair[idx];
    ll fstMin = (one.first * -1) + geta;
    ll secMin = (one.second * -1) + geta;
    REPN(i, fstMin, 100) {
      REPN(j, secMin, 100) { ans += matrix[i][j]; }
    }
    if (0 <= one.first && 0 <= one.second)
      ans--;
  }

  cout << ans / 2 << endl;
}

// メイン
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Solve();
  return 0;
}


Error: 0

Fixed submission:

#include "bits/stdc++.h"
using namespace std;

// 定義
typedef long long ll;
typedef pair<ll, ll> P;
#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (ll i = 0; i < (ll)n; ++i)
#define REPN(i, m, n) for (ll i = m; i < (ll)n; ++i)
#define REVREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define VL vector<ll>
#define VVL vector<vector<ll>>
#define VVVL vector<vector<vector<ll>>>
#define VC vector<char>
#define VVC vector<vector<char>>
#define INF (ll)2e9
#define INF_LL 1LL << 60
// #define MOD             998244353
#define MOD 1000000007

ll Ceil(ll val, ll div) { return (val + div - 1) / div; }
ll CeilN(ll val, ll div) { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n) { return (x - x % n); }
bool IsOdd(ll x) { return ((x & 1) == 1); }
bool IsEven(ll x) { return ((x & 1) == 0); }
template <class T> bool chmax(T &a, T b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a >= b) {
    a = b;
    return 1;
  }
  return 0;
}

/* baseのべき乗を求める */
template <class T> T getPower(int exponet, int base) {
  T ans = 1;
  for (int i = 0; i < exponet; i++) {
    ans *= base;
  }
  return ans;
}

void Solve() {
  ll N;
  cin >> N;
  vector<string> A(N);
  REP(i, N) cin >> A[i];

  vector<P> primePair(N);

  auto getSosuuPari = [](ll val) {
    ll tmp;
    tmp = val;
    P res = {0, 0};

    while (tmp % 2 == 0) {
      tmp /= 2;
      res.first++;
    }

    tmp = val;
    while (tmp % 5 == 0) {
      tmp /= 5;
      res.second++;
    }

    return res;
  };

  REP(i, N) {
    auto &one = A[i];
    auto pos = one.find('.');

    ll topVal;
    ll divVal;
    if (pos == string::npos) {
      divVal = 1;
      topVal = stoll(one);
    } else {
      ll strLen = one.size() - pos - 1;
      string join = one.substr(0, pos) + one.substr(pos + 1);
      divVal = getPower<ll>(strLen, 10);
      topVal = stoll(join.c_str());
    }
    P topPrime = getSosuuPari(topVal);
    P divPrime = getSosuuPari(divVal);
    primePair[i].first = topPrime.first - divPrime.first;
    primePair[i].second = topPrime.second - divPrime.second;
  }

  ll geta = 20;
  VVL matrix(50, VL(50, 0));
  for (auto &one : primePair) {
    matrix[one.first + geta][one.second + geta]++;
  }

  ll ans = 0;
  REP(idx, N) {
    auto &one = primePair[idx];
    ll fstMin = (one.first * -1) + geta;
    ll secMin = (one.second * -1) + geta;
    REPN(i, fstMin, 50) {
      REPN(j, secMin, 50) { ans += matrix[i][j]; }
    }
    if (0 <= one.first && 0 <= one.second)
      ans--;
  }

  cout << ans / 2 << endl;
}

// メイン
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Solve();
  return 0;
}