Guest User

Untitled

a guest
Feb 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main(){
  6. int numbers[28123];
  7. int sindex, cindex = 0;
  8. for(sindex = 0; sindex < 28123; sindex++)
  9. numbers[sindex] = 0 - (sindex + 1);
  10. sindex = 0;
  11. while(sindex < (int)sqrt(28123)){
  12. if(cindex >= 28123){
  13. sindex++;
  14. cindex = (sindex + 1) * 2 - 1;
  15. }
  16. if(sindex + 1 <= (int)sqrt(cindex + 1))
  17. numbers[cindex] += (sindex + 1) + ((cindex + 1) / (sindex + 1) == (sindex + 1) ? 0: (cindex + 1) / (sindex + 1));
  18. cindex += sindex + 1;
  19. }
  20. cindex = 0;
  21. for(sindex = 0; sindex < 28123; sindex++)
  22. if(numbers[sindex] > sindex + 1)
  23. cindex++;
  24. int abundants[cindex];
  25. for(sindex = 0, cindex = 0; sindex < 28123; sindex++)
  26. if(numbers[sindex] > sindex + 1){
  27. abundants[cindex] = sindex + 1;
  28. cindex++;
  29. }
  30. sindex = cindex = 0;
  31. while(sindex < sizeof(abundants) / sizeof(abundants[0])){
  32. if(cindex >= sizeof(abundants) / sizeof(abundants[0]) || abundants[sindex] + abundants[cindex] - 1 >= 28123){
  33. sindex++;
  34. cindex = sindex;
  35. }
  36. else{
  37. numbers[abundants[sindex] + abundants[cindex] - 1] = -1;
  38. cindex++;
  39. }
  40. }
  41. for(sindex = 0, cindex = 0; sindex < 28123; sindex++)
  42. if(numbers[sindex] != -1)
  43. cindex += sindex + 1;
  44. cout<< cindex << endl;
  45. system("pause");
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment