fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. //Code tot hon => chay nhanh hon, it vong lap hon
  5. int tonguoc2(int n){
  6. int sum = 0;
  7. for(int i = 1; i <= sqrt(n); i++){
  8. if(n % i == 0){
  9. sum += i;
  10. // i => n / i
  11. if(i != n / i){
  12. sum += n / i;
  13. }
  14. }
  15. }
  16. return sum;
  17. }
  18.  
  19. int demuoc(int n){
  20. int ans = 0;
  21. for(int i = 1; i <= sqrt(n); i++){
  22. if(n % i == 0){
  23. ++ans;
  24. if(i != n / i){
  25. ++ans;
  26. }
  27. }
  28. }
  29. return ans;
  30. }
  31.  
  32. int main(){
  33. int n; cin >> n;
  34. cout << tonguoc2(n) << endl;
  35. }
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
57344