fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Main
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. long sumOfDivisors = 1;
  10. Scanner in = new Scanner(System.in);
  11. long n = in.nextLong();
  12. HashMap<Long, Long> primeDivInPow = new HashMap<>();
  13. for(long i = 2; i * i <= n; i++){
  14. while(n % i == 0){
  15. if(primeDivInPow.containsKey(i) == false){
  16. primeDivInPow.put(i, (long) 1);
  17. }
  18. primeDivInPow.put(i, primeDivInPow.get(i) * i);
  19. n /= i;
  20. }
  21. }
  22. if(n != 1){
  23. primeDivInPow.put(n, n);
  24. }
  25. for (Map.Entry<Long, Long> entry : primeDivInPow.entrySet()) {
  26. sumOfDivisors *= (entry.getValue() * entry.getKey() - 1) / (entry.getKey() - 1);
  27. }
  28. System.out.println(sumOfDivisors);
  29. }
  30. }
Success #stdin #stdout 0.07s 2184192KB
stdin
2147483648
stdout
4294967295