i am unable to understand why i am getting WA, even all test cases are passing can anyone tell me what’s wrong with my code?

ll divsum(int n) {
  ll res = 1;
  for(int i = 2 ; i * i <= n; i++) {
    if (n % i == 0) {
      res += i;
      if (i * i != n){
        res += (n / i);
      }
    }
  }
  return res;
}

void solve() {
  /// write your code here
  int n;
  cin >> n;
  cout << divsum(n) << "\n";
}

int main() {
  FIO;
  ONLINE();
  int t;
  cin >> t;
  while (t--)
    solve();
  return 0;
}

NOTE -
FIO and ONLINE are macros which i have not shown here but are included in code which i submitted

  • created

    Jul '20
  • last reply

    Jul '20
  • 1

    reply

  • 715

    views

  • 2

    users

I see you’ve since got AC - what was the problem?