fork download
  1. #include <bits/stdc++.h>
  2. #define int long long
  3. using namespace std;
  4. long getDataDependenceSum(long n) {
  5. int sum = 0, x = 1;
  6. map<int, int> seen;
  7. while(x * x <= n) {
  8. if(!seen.count(x)) {
  9. sum += x;
  10. seen[x] = 1;
  11. }
  12. if(!seen.count(n / x)) {
  13. sum += n / x;
  14. seen[n / x] = 1;
  15. }
  16. x++;
  17. }
  18. return sum;
  19. }
  20. signed main()
  21. {
  22. cout << getDataDependenceSum(13) << endl;
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5280KB
stdin
5
stdout
29